grid2: add skipSpreadCheck option

This commit is contained in:
c9s 2022-12-15 18:09:43 +08:00
parent c0598a05f6
commit bc8d7e9968
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 11 additions and 3 deletions

View File

@ -83,3 +83,6 @@ exchangeStrategies:
resetPositionWhenStart: true
clearOpenOrdersWhenStart: false
keepOrdersWhenShutdown: false
## skipSpreadCheck skips the minimal spread check for the grid profit
# skipSpreadCheck: true

View File

@ -128,8 +128,9 @@ func (s *GridProfitStats) SlackAttachment() slack.Attachment {
footer += fmt.Sprintf(" since %s", s.Since.String())
}
title := fmt.Sprintf("%s Grid Profit Stats", s.Symbol)
return slack.Attachment{
Title: "Grid Profit Stats",
Title: title,
Color: "warning",
Fields: fields,
Footer: footer,

View File

@ -103,6 +103,8 @@ type Strategy struct {
// it makes sure that your grid configuration is profitable.
FeeRate fixedpoint.Value `json:"feeRate"`
SkipSpreadCheck bool `json:"skipSpreadCheck"`
GridProfitStats *GridProfitStats `persistence:"grid_profit_stats"`
ProfitStats *types.ProfitStats `persistence:"profit_stats"`
Position *types.Position `persistence:"position"`
@ -141,8 +143,10 @@ func (s *Strategy) Validate() error {
return fmt.Errorf("gridNum can not be zero")
}
if err := s.checkSpread(); err != nil {
return errors.Wrapf(err, "spread is too small, please try to reduce your gridNum or increase the price range (upperPrice and lowerPrice)")
if !s.SkipSpreadCheck {
if err := s.checkSpread(); err != nil {
return errors.Wrapf(err, "spread is too small, please try to reduce your gridNum or increase the price range (upperPrice and lowerPrice)")
}
}
if !s.QuantityOrAmount.IsSet() && s.QuoteInvestment.IsZero() {