diff --git a/pkg/strategy/marketcap/strategy.go b/pkg/strategy/marketcap/strategy.go index 14f6b7d51..81e2a3b8c 100644 --- a/pkg/strategy/marketcap/strategy.go +++ b/pkg/strategy/marketcap/strategy.go @@ -43,6 +43,12 @@ type Strategy struct { targetWeights types.ValueMap } +func (s *Strategy) Defaults() error { + if s.OrderType == "" { + s.OrderType = types.OrderTypeLimitMaker + } +} + func (s *Strategy) Initialize() error { apiKey := os.Getenv("COINMARKETCAP_API_KEY") s.datasource = coinmarketcap.New(apiKey) @@ -77,11 +83,6 @@ func (s *Strategy) Validate() error { if s.MaxAmount.Sign() < 0 { return fmt.Errorf("maxAmount shoud not less than 0") } - - if s.OrderType == "" { - s.OrderType = types.OrderTypeLimitMaker - } - return nil } diff --git a/pkg/strategy/rebalance/strategy.go b/pkg/strategy/rebalance/strategy.go index d4ba35ace..7b6a9d6bb 100644 --- a/pkg/strategy/rebalance/strategy.go +++ b/pkg/strategy/rebalance/strategy.go @@ -31,6 +31,12 @@ type Strategy struct { activeOrderBook *bbgo.ActiveOrderBook } +func (s *Strategy) Defaults() error { + if s.OrderType == "" { + s.OrderType = types.OrderTypeLimitMaker + } +} + func (s *Strategy) Initialize() error { return nil } @@ -61,11 +67,6 @@ func (s *Strategy) Validate() error { if s.MaxAmount.Sign() < 0 { return fmt.Errorf("maxAmount shoud not less than 0") } - - if s.OrderType == "" { - s.OrderType = types.OrderTypeLimitMaker - } - return nil }