mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
fix and improve position accessor
This commit is contained in:
parent
e87c2e271f
commit
9f77236999
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user