bbgo: bind market data store to market data stream when allocating new instance

This commit is contained in:
c9s 2022-07-21 12:35:38 +08:00
parent de62d9dd67
commit 1079757833
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -365,12 +365,17 @@ func (session *ExchangeSession) initSymbol(ctx context.Context, environ *Environ
orderStore.BindStream(session.UserDataStream)
session.orderStores[symbol] = orderStore
if _, ok := session.marketDataStores[symbol]; !ok {
marketDataStore := NewMarketDataStore(symbol)
marketDataStore.BindStream(session.MarketDataStream)
session.marketDataStores[symbol] = marketDataStore
}
if _, ok := session.standardIndicatorSets[symbol]; !ok {
marketDataStore := session.marketDataStores[symbol]
standardIndicatorSet := NewStandardIndicatorSet(symbol, session.MarketDataStream, marketDataStore)
session.standardIndicatorSets[symbol] = standardIndicatorSet
}
// used kline intervals by the given symbol
var klineSubscriptions = map[types.Interval]struct{}{}
@ -475,6 +480,7 @@ func (session *ExchangeSession) MarketDataStore(symbol string) (s *MarketDataSto
s, ok = session.marketDataStores[symbol]
if !ok {
s = NewMarketDataStore(symbol)
s.BindStream(session.MarketDataStream)
session.marketDataStores[symbol] = s
return s, true
}