mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
grid2: update metrics after recovering the grid orders
This commit is contained in:
parent
4b4af5a09c
commit
31c9ebf34b
|
@ -1578,6 +1578,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
if err := s.recoverGrid(ctx, session); err != nil {
|
||||
log.WithError(err).Errorf("recover error")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if err := s.openGrid(ctx, session); err != nil {
|
||||
|
@ -1596,22 +1597,24 @@ func (s *Strategy) recoverGrid(ctx context.Context, session *bbgo.ExchangeSessio
|
|||
return err
|
||||
}
|
||||
|
||||
s.logger.Infof("found %d open orders left on the %s order book", len(openOrders), s.Symbol)
|
||||
|
||||
// do recover only when openOrders > 0
|
||||
if len(openOrders) > 0 {
|
||||
historyService, implemented := session.Exchange.(types.ExchangeTradeHistoryService)
|
||||
if !implemented {
|
||||
s.logger.Warn("ExchangeTradeHistoryService is not implemented, can not recover grid")
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := s.recoverGridWithOpenOrders(ctx, historyService, openOrders); err != nil {
|
||||
return errors.Wrap(err, "recover grid error")
|
||||
}
|
||||
if len(openOrders) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
s.logger.Infof("found %d open orders left on the %s order book", len(openOrders), s.Symbol)
|
||||
|
||||
historyService, implemented := session.Exchange.(types.ExchangeTradeHistoryService)
|
||||
if !implemented {
|
||||
s.logger.Warn("ExchangeTradeHistoryService is not implemented, can not recover grid")
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := s.recoverGridWithOpenOrders(ctx, historyService, openOrders); err != nil {
|
||||
return errors.Wrap(err, "recover grid error")
|
||||
}
|
||||
|
||||
s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders())
|
||||
}
|
||||
|
||||
// openOrdersMismatches verifies if the open orders are on the grid pins
|
||||
|
|
Loading…
Reference in New Issue
Block a user