From 199b86df865b848c5854cee42eb91d11327b7ccc Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 27 Aug 2024 14:52:27 +0800 Subject: [PATCH] xmaker: add comments --- pkg/strategy/xmaker/strategy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/xmaker/strategy.go b/pkg/strategy/xmaker/strategy.go index b8b8c5c8e..91c21bcfd 100644 --- a/pkg/strategy/xmaker/strategy.go +++ b/pkg/strategy/xmaker/strategy.go @@ -1037,8 +1037,12 @@ func (s *Strategy) CrossRun( go s.quoteWorker(ctx) bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) { + // the ctx here is the shutdown context (not the strategy context) + + // defer work group done to mark the strategy as stopped defer wg.Done() + // send stop signal to the quoteWorker close(s.stopC) // wait for the quoter to stop @@ -1048,7 +1052,7 @@ func (s *Strategy) CrossRun( log.WithError(err).Errorf("graceful cancel error") } - bbgo.Notify("%s: %s position", ID, s.Symbol, s.Position) + bbgo.Notify("Shutting down %s %s", ID, s.Symbol, s.Position) }) return nil