From f039c97e63ad9923dfeb54c292eac67e032f246a Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 16 Feb 2023 18:12:08 +0800 Subject: [PATCH] grid2: defer EmitCloseGrid callback earlier --- pkg/strategy/grid2/strategy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index 62cde968c..378fc0893 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -776,6 +776,8 @@ func (s *Strategy) OpenGrid(ctx context.Context) error { func (s *Strategy) CloseGrid(ctx context.Context) error { s.logger.Infof("closing %s grid", s.Symbol) + defer s.EmitGridClosed() + bbgo.Sync(ctx, s) // now we can cancel the open orders @@ -786,7 +788,6 @@ func (s *Strategy) CloseGrid(ctx context.Context) error { // free the grid object s.setGrid(nil) - s.EmitGridClosed() return nil }