FIX: fix dca2 panic problem

This commit is contained in:
kbearXD 2024-04-11 11:40:19 +08:00
parent ffb2b27bc6
commit 2d45b5cb76
2 changed files with 13 additions and 4 deletions

View File

@ -52,10 +52,11 @@ func (s *Strategy) recoverActiveOrders(ctx context.Context) error {
}
opts := common.SyncActiveOrdersOpts{
Logger: s.logger,
Exchange: s.ExchangeSession.Exchange,
ActiveOrderBook: activeOrders,
OpenOrders: openOrders,
Logger: s.logger,
Exchange: s.ExchangeSession.Exchange,
OrderQueryService: s.orderQueryService,
ActiveOrderBook: activeOrders,
OpenOrders: openOrders,
}
return common.SyncActiveOrders(ctx, opts)

View File

@ -94,6 +94,7 @@ type Strategy struct {
nextStateC chan State
state State
roundCollector *RoundCollector
orderQueryService types.ExchangeOrderQueryService
takeProfitPrice fixedpoint.Value
startTimeOfNextRound time.Time
nextRoundPaused bool
@ -193,6 +194,13 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.OrderGroupID = util.FNV32(instanceID) % math.MaxInt32
}
// orderQueryService
if service, ok := s.ExchangeSession.Exchange.(types.ExchangeOrderQueryService); ok {
s.orderQueryService = service
} else {
return fmt.Errorf("exchange %s doesn't support ExchangeOrderQueryService", s.ExchangeSession.ExchangeName)
}
// round collector
s.roundCollector = NewRoundCollector(s.logger, s.Symbol, s.OrderGroupID, s.ExchangeSession.Exchange)
if s.roundCollector == nil {