set order type default value in Defaults method

This commit is contained in:
なるみ 2023-03-06 12:33:14 +00:00
parent 94b946a993
commit cd500e6e73
2 changed files with 12 additions and 10 deletions

View File

@ -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
}

View File

@ -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
}