diff --git a/pkg/strategy/support/strategy.go b/pkg/strategy/support/strategy.go index 9918ec529..bfb5d3e5d 100644 --- a/pkg/strategy/support/strategy.go +++ b/pkg/strategy/support/strategy.go @@ -44,6 +44,18 @@ func (s *Strategy) ID() string { return ID } +func (s *Strategy) Validate() error { + if s.Quantity == 0 && s.ScaleQuantity == nil { + return fmt.Errorf("quantity or scaleQuantity can not be zero") + } + + if s.MinVolume == 0 { + return fmt.Errorf("minVolume can not be zero") + } + + return nil +} + func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: string(s.Interval)}) } @@ -58,14 +70,6 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se s.MovingAverageWindow = 99 } - if s.Quantity == 0 && s.ScaleQuantity == nil { - return fmt.Errorf("quantity or scaleQuantity can not be zero") - } - - if s.MinVolume == 0 { - return fmt.Errorf("minVolume can not be zero") - } - // buy when price drops -8% market, ok := session.Market(s.Symbol) if !ok {