grid2: defer EmitCloseGrid callback earlier

This commit is contained in:
c9s 2023-02-16 18:12:08 +08:00
parent 7ba0e86605
commit f039c97e63
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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
}