From ee6db5c0e5614db5067a0038fc4589916ffdbea2 Mon Sep 17 00:00:00 2001 From: kbearXD Date: Tue, 19 Mar 2024 15:43:40 +0800 Subject: [PATCH] dca2: fix order group id not set issue --- pkg/strategy/dca2/strategy.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/strategy/dca2/strategy.go b/pkg/strategy/dca2/strategy.go index 89307f98ab..65799e676d 100644 --- a/pkg/strategy/dca2/strategy.go +++ b/pkg/strategy/dca2/strategy.go @@ -172,6 +172,10 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo. s.Position = types.NewPositionFromMarket(s.Market) } + if s.OrderGroupID == 0 { + s.OrderGroupID = util.FNV32(instanceID) % math.MaxInt32 + } + // round collector s.roundCollector = NewRoundCollector(s.logger, s.Symbol, s.OrderGroupID, s.ExchangeSession.Exchange) if s.roundCollector == nil { @@ -207,10 +211,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo. s.OrderExecutor.BindEnvironment(s.Environment) s.OrderExecutor.Bind() - if s.OrderGroupID == 0 { - s.OrderGroupID = util.FNV32(instanceID) % math.MaxInt32 - } - // order executor s.OrderExecutor.TradeCollector().OnPositionUpdate(func(position *types.Position) { s.logger.Infof("POSITION UPDATE: %s", s.Position.String())