grid2: update metrics and trigger ready callback

This commit is contained in:
c9s 2023-04-06 23:24:08 +08:00
parent 542467245e
commit fba73f11ea
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -6,10 +6,11 @@ import (
"strconv"
"time"
"github.com/pkg/errors"
"github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
"github.com/pkg/errors"
)
func (s *Strategy) recoverByScanningTrades(ctx context.Context, session *bbgo.ExchangeSession) error {
@ -77,6 +78,9 @@ func (s *Strategy) recoverWithOpenOrdersByScanningTrades(ctx context.Context, hi
s.debugLog("open orders nums: %d, expected nums: %d", openOrdersOnGridNums, expectedOrderNums)
if expectedOrderNums == openOrdersOnGridNums {
// no need to recover
s.EmitGridReady()
s.updateGridNumOfOrdersMetricsWithLock()
s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders())
return nil
} else if expectedOrderNums < openOrdersOnGridNums {
return fmt.Errorf("amount of grid's open orders should not > amount of expected grid's orders")