Skip to content

Commit

Permalink
dca2: fix order group id not set issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kbearXD committed Mar 19, 2024
1 parent 3f44092 commit ee6db5c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/strategy/dca2/strategy.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit ee6db5c

Please sign in to comment.