From cd500e6e7391d230f6de61d1823f0b4df13e3a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=81=BF?= <4680567+narumiruna@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:33:14 +0000 Subject: [PATCH] set order type default value in Defaults method --- pkg/strategy/marketcap/strategy.go | 11 ++++++----- pkg/strategy/rebalance/strategy.go | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) 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 }