fix/profitStatsTracker: market is initiated after strategy Subscribe()

This commit is contained in:
Andy Cheng 2023-07-10 16:01:20 +08:00
parent 2ccce12cbf
commit 4c1639cf00
No known key found for this signature in database
GPG Key ID: 936427CF651A9D28
2 changed files with 3 additions and 3 deletions

View File

@ -20,8 +20,8 @@ type ProfitStatsTracker struct {
tradeStats *types.TradeStats tradeStats *types.TradeStats
} }
func (p *ProfitStatsTracker) Subscribe(session *bbgo.ExchangeSession) { func (p *ProfitStatsTracker) Subscribe(session *bbgo.ExchangeSession, symbol string) {
session.Subscribe(types.KLineChannel, p.Market.Symbol, types.SubscribeOptions{Interval: p.Interval}) session.Subscribe(types.KLineChannel, symbol, types.SubscribeOptions{Interval: p.Interval})
} }
// InitOld is for backward capability. ps is the ProfitStats of the strategy, Market is the strategy Market // InitOld is for backward capability. ps is the ProfitStats of the strategy, Market is the strategy Market

View File

@ -133,7 +133,7 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
// Profit tracker // Profit tracker
if s.ProfitStatsTracker != nil { if s.ProfitStatsTracker != nil {
s.ProfitStatsTracker.Subscribe(session) s.ProfitStatsTracker.Subscribe(session, s.Symbol)
} }
} }