grid2: fix quantity, amount, quoteInvestment validation

This commit is contained in:
c9s 2022-12-07 12:29:14 +08:00
parent df6187dc98
commit 9215e401d0

View File

@ -133,17 +133,11 @@ func (s *Strategy) Validate() error {
} }
if err := s.checkSpread(); err != nil { if err := s.checkSpread(); err != nil {
return err return errors.Wrapf(err, "spread is too small, please try to reduce your gridNum or increase the price range (upperPrice and lowerPrice)")
} }
if err := s.QuantityOrAmount.Validate(); err != nil { if !s.QuantityOrAmount.IsSet() && s.QuoteInvestment.IsZero() {
if s.QuoteInvestment.IsZero() && s.BaseInvestment.IsZero() { return fmt.Errorf("either quantity, amount or quoteInvestment must be set")
return err
}
}
if !s.QuantityOrAmount.IsSet() && s.QuoteInvestment.IsZero() && s.BaseInvestment.IsZero() {
return fmt.Errorf("one of quantity, amount, quoteInvestment must be set")
} }
return nil return nil