From 58a13507bc1a51c25c0f35a53084670642fd33e8 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 19 Jun 2023 15:22:43 +0800 Subject: [PATCH] scmaker: graceful cancel orders --- pkg/strategy/scmaker/strategy.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/strategy/scmaker/strategy.go b/pkg/strategy/scmaker/strategy.go index 83a7bc6e6..d166a2154 100644 --- a/pkg/strategy/scmaker/strategy.go +++ b/pkg/strategy/scmaker/strategy.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math" + "sync" log "github.com/sirupsen/logrus" @@ -152,6 +153,16 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se } }) + bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) { + defer wg.Done() + + err := s.liquidityOrderBook.GracefulCancel(ctx, s.session.Exchange) + logErr(err, "unable to cancel liquidity orders") + + err = s.adjustmentOrderBook.GracefulCancel(ctx, s.session.Exchange) + logErr(err, "unable to cancel adjustment orders") + }) + return nil }