mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
FIX: fix emit ready twice and add error log
This commit is contained in:
parent
d63734f365
commit
a0aae23bf3
|
@ -58,13 +58,12 @@ 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())
|
||||
// emit ready after recover
|
||||
s.EmitGridReady()
|
||||
s.updateGridNumOfOrdersMetricsWithLock()
|
||||
s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders())
|
||||
|
||||
|
@ -88,9 +87,6 @@ func (s *Strategy) recoverWithOpenOrdersByScanningTrades(ctx context.Context, hi
|
|||
s.debugLog("open orders nums: %d, expected nums: %d", numGridOpenOrders, expectedNumOfOrders)
|
||||
if expectedNumOfOrders == numGridOpenOrders {
|
||||
// no need to recover
|
||||
s.EmitGridReady()
|
||||
s.updateGridNumOfOrdersMetricsWithLock()
|
||||
s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders())
|
||||
return nil
|
||||
} else if expectedNumOfOrders < numGridOpenOrders {
|
||||
return fmt.Errorf("amount of grid's open orders should not > amount of expected grid's orders")
|
||||
|
|
|
@ -1941,6 +1941,7 @@ func (s *Strategy) startProcess(ctx context.Context, session *bbgo.ExchangeSessi
|
|||
s.logger.Infof("recoverWhenStart is set, trying to recover grid orders...")
|
||||
if err := s.recoverGrid(ctx, session); err != nil {
|
||||
// if recover fail, return and do not open grid
|
||||
s.logger.WithError(err).Error("failed to start process, recover error")
|
||||
s.EmitGridError(errors.Wrapf(err, "failed to start process, recover error"))
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user