From 74e01ce444ddd2d0efe7d5ead23fa838bb3c589c Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 9 May 2021 19:44:51 +0800 Subject: [PATCH] fix order waiting for graceful shutdown --- pkg/strategy/xmaker/strategy.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/strategy/xmaker/strategy.go b/pkg/strategy/xmaker/strategy.go index c5e2db1c5..6ec7a732a 100644 --- a/pkg/strategy/xmaker/strategy.go +++ b/pkg/strategy/xmaker/strategy.go @@ -493,7 +493,6 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se position := s.state.HedgePosition.AtomicLoad() abspos := math.Abs(position.Float64()) if !s.DisableHedge && abspos > s.sourceMarket.MinQuantity { - log.Infof("found position: %f", position.Float64()) s.Hedge(ctx, -position) } } @@ -512,14 +511,16 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se } for { + log.Warnf("waiting for orders to be cancelled...") + time.Sleep(1 * time.Second) + orders := s.activeMakerOrders.Orders() if len(orders) == 0 { log.Info("all orders are cancelled successfully") break } - log.Warnf("waiting for %d orders to be cancelled...", len(orders)) - time.Sleep(1 * time.Second) + log.Warnf("%d orders are not cancelled yet...", len(orders)) } if err := s.Persistence.Save(s.state, ID, s.Symbol, stateKey); err != nil {