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) orderStore.BindStream(session.UserDataStream)
session.orderStores[symbol] = orderStore session.orderStores[symbol] = orderStore
marketDataStore := NewMarketDataStore(symbol) if _, ok := session.marketDataStores[symbol]; !ok {
marketDataStore.BindStream(session.MarketDataStream) marketDataStore := NewMarketDataStore(symbol)
session.marketDataStores[symbol] = marketDataStore marketDataStore.BindStream(session.MarketDataStream)
session.marketDataStores[symbol] = marketDataStore
}
standardIndicatorSet := NewStandardIndicatorSet(symbol, session.MarketDataStream, marketDataStore) if _, ok := session.standardIndicatorSets[symbol]; !ok {
session.standardIndicatorSets[symbol] = standardIndicatorSet marketDataStore := session.marketDataStores[symbol]
standardIndicatorSet := NewStandardIndicatorSet(symbol, session.MarketDataStream, marketDataStore)
session.standardIndicatorSets[symbol] = standardIndicatorSet
}
// used kline intervals by the given symbol // used kline intervals by the given symbol
var klineSubscriptions = map[types.Interval]struct{}{} var klineSubscriptions = map[types.Interval]struct{}{}
@ -475,6 +480,7 @@ func (session *ExchangeSession) MarketDataStore(symbol string) (s *MarketDataSto
s, ok = session.marketDataStores[symbol] s, ok = session.marketDataStores[symbol]
if !ok { if !ok {
s = NewMarketDataStore(symbol) s = NewMarketDataStore(symbol)
s.BindStream(session.MarketDataStream)
session.marketDataStores[symbol] = s session.marketDataStores[symbol] = s
return s, true return s, true
} }