xgap: check sourceSymbol

This commit is contained in:
c9s 2024-11-15 23:43:28 +08:00
parent 2ea0c86c67
commit ab9faba1af
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -105,13 +105,15 @@ func (s *Strategy) Defaults() error {
} }
func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) { func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) {
sourceSession, ok := sessions[s.SourceExchange] if len(s.SourceExchange) > 0 && len(s.SourceSymbol) > 0 {
if !ok { sourceSession, ok := sessions[s.SourceExchange]
panic(fmt.Errorf("source session %s is not defined", s.SourceExchange)) if !ok {
} panic(fmt.Errorf("source session %s is not defined", s.SourceExchange))
}
sourceSession.Subscribe(types.KLineChannel, s.SourceSymbol, types.SubscribeOptions{Interval: "1m"}) sourceSession.Subscribe(types.KLineChannel, s.SourceSymbol, types.SubscribeOptions{Interval: "1m"})
sourceSession.Subscribe(types.BookChannel, s.SourceSymbol, types.SubscribeOptions{Depth: types.DepthLevel5}) sourceSession.Subscribe(types.BookChannel, s.SourceSymbol, types.SubscribeOptions{Depth: types.DepthLevel5})
}
tradingSession, ok := sessions[s.TradingExchange] tradingSession, ok := sessions[s.TradingExchange]
if !ok { if !ok {