From f5873172decf49e668e40b0b4643206bc426f0e0 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 6 Mar 2024 16:10:22 +0800 Subject: [PATCH] xdepthmaker: fix use of uninitialized vars --- pkg/strategy/xdepthmaker/strategy.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/strategy/xdepthmaker/strategy.go b/pkg/strategy/xdepthmaker/strategy.go index 9e2f10d69..53bc918cf 100644 --- a/pkg/strategy/xdepthmaker/strategy.go +++ b/pkg/strategy/xdepthmaker/strategy.go @@ -325,18 +325,23 @@ func (s *Strategy) CrossRun( } fixer := NewProfitFixer(s.makerMarket) - fixer.AddExchange(s.makerSession.Name, s.makerSession.Exchange.(types.ExchangeTradeHistoryService)) - fixer.AddExchange(s.hedgeSession.Name, s.hedgeSession.Exchange.(types.ExchangeTradeHistoryService)) + fixer.AddExchange(makerSession.Name, makerSession.Exchange.(types.ExchangeTradeHistoryService)) + fixer.AddExchange(hedgeSession.Name, hedgeSession.Exchange.(types.ExchangeTradeHistoryService)) - s.CrossExchangeMarketMakingStrategy.Position = types.NewPositionFromMarket(s.makerMarket) - s.CrossExchangeMarketMakingStrategy.ProfitStats = types.NewProfitStats(s.makerMarket) + makerMarket, _ := s.makerSession.Market(s.Symbol) + s.CrossExchangeMarketMakingStrategy.Position = types.NewPositionFromMarket(makerMarket) + s.CrossExchangeMarketMakingStrategy.ProfitStats = types.NewProfitStats(makerMarket) if err2 := fixer.Fix(ctx, s.ProfitFixerConfig.TradesSince.Time(), time.Now(), s.CrossExchangeMarketMakingStrategy.ProfitStats, s.CrossExchangeMarketMakingStrategy.Position); err2 != nil { return err2 } } - if err := s.CrossExchangeMarketMakingStrategy.Initialize(ctx, s.Environment, makerSession, hedgeSession, s.Symbol, ID, s.InstanceID()); err != nil { + if err := s.CrossExchangeMarketMakingStrategy.Initialize(ctx, + s.Environment, + makerSession, + hedgeSession, + s.Symbol, ID, s.InstanceID()); err != nil { return err }