From abd41c98de1fdecb76e13488121d53ddd5afa494 Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 15 Nov 2024 23:48:23 +0800 Subject: [PATCH] xgap: call tradingutil.UniversalCancelAllOrders --- pkg/strategy/xgap/strategy.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/strategy/xgap/strategy.go b/pkg/strategy/xgap/strategy.go index 2be2f527c..434b4e015 100644 --- a/pkg/strategy/xgap/strategy.go +++ b/pkg/strategy/xgap/strategy.go @@ -15,6 +15,7 @@ import ( "github.com/c9s/bbgo/pkg/strategy/common" "github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/util/timejitter" + "github.com/c9s/bbgo/pkg/util/tradingutil" ) const ID = "xgap" @@ -154,6 +155,11 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) { defer wg.Done() + + if err := tradingutil.UniversalCancelAllOrders(ctx, s.tradingSession.Exchange, s.Symbol, nil); err != nil { + s.logger.WithError(err).Errorf("cancel all orders error") + } + close(s.stopC) bbgo.Sync(ctx, s) })