mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix order waiting for graceful shutdown
This commit is contained in:
parent
e06310da26
commit
74e01ce444
|
@ -493,7 +493,6 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
||||||
position := s.state.HedgePosition.AtomicLoad()
|
position := s.state.HedgePosition.AtomicLoad()
|
||||||
abspos := math.Abs(position.Float64())
|
abspos := math.Abs(position.Float64())
|
||||||
if !s.DisableHedge && abspos > s.sourceMarket.MinQuantity {
|
if !s.DisableHedge && abspos > s.sourceMarket.MinQuantity {
|
||||||
log.Infof("found position: %f", position.Float64())
|
|
||||||
s.Hedge(ctx, -position)
|
s.Hedge(ctx, -position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,14 +511,16 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
log.Warnf("waiting for orders to be cancelled...")
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
orders := s.activeMakerOrders.Orders()
|
orders := s.activeMakerOrders.Orders()
|
||||||
if len(orders) == 0 {
|
if len(orders) == 0 {
|
||||||
log.Info("all orders are cancelled successfully")
|
log.Info("all orders are cancelled successfully")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Warnf("waiting for %d orders to be cancelled...", len(orders))
|
log.Warnf("%d orders are not cancelled yet...", len(orders))
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.Persistence.Save(s.state, ID, s.Symbol, stateKey); err != nil {
|
if err := s.Persistence.Save(s.state, ID, s.Symbol, stateKey); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user