Merge pull request #1594 from c9s/kbearXD/dca2/round-collector

FIX: [dca2] fix order group id not set issue
This commit is contained in:
kbearXD 2024-03-19 16:03:41 +08:00 committed by GitHub
commit 819fc59340
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -186,6 +186,10 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.Position.SetTTL(s.PersistenceTTL.Duration()) s.Position.SetTTL(s.PersistenceTTL.Duration())
s.ProfitStats.SetTTL(s.PersistenceTTL.Duration()) s.ProfitStats.SetTTL(s.PersistenceTTL.Duration())
if s.OrderGroupID == 0 {
s.OrderGroupID = util.FNV32(instanceID) % math.MaxInt32
}
// round collector // round collector
s.roundCollector = NewRoundCollector(s.logger, s.Symbol, s.OrderGroupID, s.ExchangeSession.Exchange) s.roundCollector = NewRoundCollector(s.logger, s.Symbol, s.OrderGroupID, s.ExchangeSession.Exchange)
if s.roundCollector == nil { if s.roundCollector == nil {
@ -215,10 +219,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.OrderExecutor.BindEnvironment(s.Environment) s.OrderExecutor.BindEnvironment(s.Environment)
s.OrderExecutor.Bind() s.OrderExecutor.Bind()
if s.OrderGroupID == 0 {
s.OrderGroupID = util.FNV32(instanceID) % math.MaxInt32
}
// order executor // order executor
s.OrderExecutor.TradeCollector().OnPositionUpdate(func(position *types.Position) { s.OrderExecutor.TradeCollector().OnPositionUpdate(func(position *types.Position) {
s.logger.Infof("POSITION UPDATE: %s", s.Position.String()) s.logger.Infof("POSITION UPDATE: %s", s.Position.String())