mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-13 02:23:51 +00:00
FIX: fix dca2 panic problem
This commit is contained in:
parent
ffb2b27bc6
commit
2d45b5cb76
|
@ -54,6 +54,7 @@ func (s *Strategy) recoverActiveOrders(ctx context.Context) error {
|
||||||
opts := common.SyncActiveOrdersOpts{
|
opts := common.SyncActiveOrdersOpts{
|
||||||
Logger: s.logger,
|
Logger: s.logger,
|
||||||
Exchange: s.ExchangeSession.Exchange,
|
Exchange: s.ExchangeSession.Exchange,
|
||||||
|
OrderQueryService: s.orderQueryService,
|
||||||
ActiveOrderBook: activeOrders,
|
ActiveOrderBook: activeOrders,
|
||||||
OpenOrders: openOrders,
|
OpenOrders: openOrders,
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ type Strategy struct {
|
||||||
nextStateC chan State
|
nextStateC chan State
|
||||||
state State
|
state State
|
||||||
roundCollector *RoundCollector
|
roundCollector *RoundCollector
|
||||||
|
orderQueryService types.ExchangeOrderQueryService
|
||||||
takeProfitPrice fixedpoint.Value
|
takeProfitPrice fixedpoint.Value
|
||||||
startTimeOfNextRound time.Time
|
startTimeOfNextRound time.Time
|
||||||
nextRoundPaused bool
|
nextRoundPaused bool
|
||||||
|
@ -193,6 +194,13 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
||||||
s.OrderGroupID = util.FNV32(instanceID) % math.MaxInt32
|
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
|
// 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 {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user