fix and improve position accessor

This commit is contained in:
c9s 2021-04-28 19:32:49 +08:00
parent e87c2e271f
commit 9f77236999

View File

@ -412,6 +412,22 @@ func (session *ExchangeSession) StandardIndicatorSet(symbol string) (*StandardIn
func (session *ExchangeSession) Position(symbol string) (pos *Position, ok bool) {
pos, ok = session.positions[symbol]
if ok {
return pos, ok
}
market, ok := session.markets[symbol]
if !ok {
return nil, false
}
pos = &Position{
Symbol: symbol,
BaseCurrency: market.BaseCurrency,
QuoteCurrency: market.QuoteCurrency,
}
ok = true
session.positions[symbol] = pos
return pos, ok
}