grid2: add StopIfLessThanMinimalQuoteInvestment option

This commit is contained in:
c9s 2023-03-02 15:50:10 +08:00
parent 01ecdc8d6b
commit 11329dffe7
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -137,8 +137,11 @@ type Strategy struct {
// UseCancelAllOrdersApiWhenClose uses a different API to cancel all the orders on the market when closing a grid
UseCancelAllOrdersApiWhenClose bool `json:"useCancelAllOrdersApiWhenClose"`
// ResetPositionWhenStart resets the position when the strategy is started
ResetPositionWhenStart bool `json:"resetPositionWhenStart"`
StopIfLessThanMinimalQuoteInvestment bool `json:"stopIfLessThanMinimalQuoteInvestment"`
// PrometheusLabels will be used as the base prometheus labels
PrometheusLabels prometheus.Labels `json:"prometheusLabels"`
@ -1612,8 +1615,13 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
if s.QuoteInvestment.Sign() > 0 {
grid := s.newGrid()
if err := s.checkMinimalQuoteInvestment(grid); err != nil {
s.logger.Errorf("check minimal quote investment failed, market info: %+v", s.Market)
return err
if s.StopIfLessThanMinimalQuoteInvestment {
s.logger.WithError(err).Errorf("check minimal quote investment failed, market info: %+v", s.Market)
return err
} else {
// if no, just warning
s.logger.WithError(err).Warnf("minimal quote investment may be not enough, market info: %+v", s.Market)
}
}
}