Skip to content

Commit

Permalink
Merge pull request #1594 from c9s/kbearXD/dca2/round-collector
Browse files Browse the repository at this point in the history
FIX: [dca2] fix order group id not set issue
  • Loading branch information
kbearXD committed Mar 19, 2024
2 parents b0bbf3c + 25baf49 commit 819fc59
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/strategy/dca2/strategy.go
Expand Up @@ -186,6 +186,10 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.Position.SetTTL(s.PersistenceTTL.Duration())
s.ProfitStats.SetTTL(s.PersistenceTTL.Duration())

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 @@ -215,10 +219,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 819fc59

Please sign in to comment.