From cc5ebd5b2cd8d654b24fece4023fcced201b5034 Mon Sep 17 00:00:00 2001 From: chiahung Date: Thu, 6 Apr 2023 23:57:54 +0800 Subject: [PATCH] move emit ready and update metrics --- pkg/strategy/grid2/recover.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/strategy/grid2/recover.go b/pkg/strategy/grid2/recover.go index 1f8f8a791..aaecea880 100644 --- a/pkg/strategy/grid2/recover.go +++ b/pkg/strategy/grid2/recover.go @@ -58,6 +58,16 @@ func (s *Strategy) recoverByScanningTrades(ctx context.Context, session *bbgo.Ex return errors.Wrap(err, "grid recover error") } + // emit ready after recover + s.EmitGridReady() + + // debug and send metrics + // wait for the reverse order to be placed + time.Sleep(2 * time.Second) + debugGrid(s.logger, s.grid, s.orderExecutor.ActiveMakerOrders()) + s.updateGridNumOfOrdersMetricsWithLock() + s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders()) + return nil } @@ -122,16 +132,6 @@ func (s *Strategy) recoverWithOpenOrdersByScanningTrades(ctx context.Context, hi activeOrderBook.EmitFilled(filledOrder) } - // 6. emit grid ready - s.EmitGridReady() - - // 7. debug and send metrics - // wait for the reverse order to be placed - time.Sleep(2 * time.Second) - debugGrid(s.logger, grid, s.orderExecutor.ActiveMakerOrders()) - s.updateGridNumOfOrdersMetricsWithLock() - s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders()) - return nil }