mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +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")
|
return errors.Wrap(err, "grid recover error")
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit ready after recover
|
|
||||||
s.EmitGridReady()
|
|
||||||
|
|
||||||
// debug and send metrics
|
// debug and send metrics
|
||||||
// wait for the reverse order to be placed
|
// wait for the reverse order to be placed
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
debugGrid(s.logger, s.grid, s.orderExecutor.ActiveMakerOrders())
|
debugGrid(s.logger, s.grid, s.orderExecutor.ActiveMakerOrders())
|
||||||
|
// emit ready after recover
|
||||||
|
s.EmitGridReady()
|
||||||
s.updateGridNumOfOrdersMetricsWithLock()
|
s.updateGridNumOfOrdersMetricsWithLock()
|
||||||
s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders())
|
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)
|
s.debugLog("open orders nums: %d, expected nums: %d", numGridOpenOrders, expectedNumOfOrders)
|
||||||
if expectedNumOfOrders == numGridOpenOrders {
|
if expectedNumOfOrders == numGridOpenOrders {
|
||||||
// no need to recover
|
// no need to recover
|
||||||
s.EmitGridReady()
|
|
||||||
s.updateGridNumOfOrdersMetricsWithLock()
|
|
||||||
s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders())
|
|
||||||
return nil
|
return nil
|
||||||
} else if expectedNumOfOrders < numGridOpenOrders {
|
} else if expectedNumOfOrders < numGridOpenOrders {
|
||||||
return fmt.Errorf("amount of grid's open orders should not > amount of expected grid's orders")
|
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...")
|
s.logger.Infof("recoverWhenStart is set, trying to recover grid orders...")
|
||||||
if err := s.recoverGrid(ctx, session); err != nil {
|
if err := s.recoverGrid(ctx, session); err != nil {
|
||||||
// if recover fail, return and do not open grid
|
// 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"))
|
s.EmitGridError(errors.Wrapf(err, "failed to start process, recover error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user