@@ -1341,8 +1341,11 @@ func (s *Strategy) recoverGridWithOpenOrders(ctx context.Context, historyService
1341
1341
missingPrices := scanMissingPinPrices (orderBook , grid .Pins )
1342
1342
if numMissing := len (missingPrices ); numMissing <= 1 {
1343
1343
s .logger .Infof ("GRID RECOVER: no missing grid prices, stop re-playing order history" )
1344
+ s .addOrdersToActiveOrderBook (gridOrders )
1344
1345
s .setGrid (grid )
1345
1346
s .EmitGridReady ()
1347
+ s .updateGridNumOfOrdersMetrics ()
1348
+ s .updateOpenOrderPricesMetrics (s .orderExecutor .ActiveMakerOrders ().Orders ())
1346
1349
return nil
1347
1350
} else {
1348
1351
s .logger .Infof ("GRID RECOVER: found missing prices: %v" , missingPrices )
@@ -1384,8 +1387,11 @@ func (s *Strategy) recoverGridWithOpenOrders(ctx context.Context, historyService
1384
1387
// if all orders on the order book are active orders, we don't need to recover.
1385
1388
if isCompleteGridOrderBook (orderBook , s .GridNum ) {
1386
1389
s .logger .Infof ("GRID RECOVER: all orders are active orders, do not need recover" )
1390
+ s .addOrdersToActiveOrderBook (gridOrders )
1387
1391
s .setGrid (grid )
1388
1392
s .EmitGridReady ()
1393
+ s .updateGridNumOfOrdersMetrics ()
1394
+ s .updateOpenOrderPricesMetrics (s .orderExecutor .ActiveMakerOrders ().Orders ())
1389
1395
return nil
1390
1396
}
1391
1397
@@ -1407,11 +1413,7 @@ func (s *Strategy) recoverGridWithOpenOrders(ctx context.Context, historyService
1407
1413
1408
1414
// before we re-play the orders,
1409
1415
// we need to add these open orders to the active order book
1410
- activeOrderBook := s .orderExecutor .ActiveMakerOrders ()
1411
- for _ , gridOrder := range gridOrders {
1412
- // put the order back to the active order book so that we can receive order update
1413
- activeOrderBook .Add (gridOrder )
1414
- }
1416
+ s .addOrdersToActiveOrderBook (gridOrders )
1415
1417
1416
1418
s .setGrid (grid )
1417
1419
s .EmitGridReady ()
@@ -1435,6 +1437,14 @@ func (s *Strategy) recoverGridWithOpenOrders(ctx context.Context, historyService
1435
1437
return nil
1436
1438
}
1437
1439
1440
+ func (s * Strategy ) addOrdersToActiveOrderBook (gridOrders []types.Order ) {
1441
+ activeOrderBook := s .orderExecutor .ActiveMakerOrders ()
1442
+ for _ , gridOrder := range gridOrders {
1443
+ // put the order back to the active order book so that we can receive order update
1444
+ activeOrderBook .Add (gridOrder )
1445
+ }
1446
+ }
1447
+
1438
1448
func (s * Strategy ) setGrid (grid * Grid ) {
1439
1449
s .mu .Lock ()
1440
1450
s .grid = grid
@@ -1857,4 +1867,4 @@ func roundUpMarketQuantity(market types.Market, v fixedpoint.Value, c string) (f
1857
1867
}
1858
1868
1859
1869
return v .Round (prec , fixedpoint .Up ), prec
1860
- }
1870
+ }
0 commit comments