move emit ready and update metrics

This commit is contained in:
chiahung 2023-04-06 23:57:54 +08:00
parent fba73f11ea
commit cc5ebd5b2c

View File

@ -58,6 +58,16 @@ func (s *Strategy) recoverByScanningTrades(ctx context.Context, session *bbgo.Ex
return errors.Wrap(err, "grid recover error") 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 return nil
} }
@ -122,16 +132,6 @@ func (s *Strategy) recoverWithOpenOrdersByScanningTrades(ctx context.Context, hi
activeOrderBook.EmitFilled(filledOrder) 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 return nil
} }