mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
set order type default value in Defaults method
This commit is contained in:
parent
94b946a993
commit
cd500e6e73
|
@ -43,6 +43,12 @@ type Strategy struct {
|
||||||
targetWeights types.ValueMap
|
targetWeights types.ValueMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Strategy) Defaults() error {
|
||||||
|
if s.OrderType == "" {
|
||||||
|
s.OrderType = types.OrderTypeLimitMaker
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Strategy) Initialize() error {
|
func (s *Strategy) Initialize() error {
|
||||||
apiKey := os.Getenv("COINMARKETCAP_API_KEY")
|
apiKey := os.Getenv("COINMARKETCAP_API_KEY")
|
||||||
s.datasource = coinmarketcap.New(apiKey)
|
s.datasource = coinmarketcap.New(apiKey)
|
||||||
|
@ -77,11 +83,6 @@ func (s *Strategy) Validate() error {
|
||||||
if s.MaxAmount.Sign() < 0 {
|
if s.MaxAmount.Sign() < 0 {
|
||||||
return fmt.Errorf("maxAmount shoud not less than 0")
|
return fmt.Errorf("maxAmount shoud not less than 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.OrderType == "" {
|
|
||||||
s.OrderType = types.OrderTypeLimitMaker
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,12 @@ type Strategy struct {
|
||||||
activeOrderBook *bbgo.ActiveOrderBook
|
activeOrderBook *bbgo.ActiveOrderBook
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Strategy) Defaults() error {
|
||||||
|
if s.OrderType == "" {
|
||||||
|
s.OrderType = types.OrderTypeLimitMaker
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Strategy) Initialize() error {
|
func (s *Strategy) Initialize() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -61,11 +67,6 @@ func (s *Strategy) Validate() error {
|
||||||
if s.MaxAmount.Sign() < 0 {
|
if s.MaxAmount.Sign() < 0 {
|
||||||
return fmt.Errorf("maxAmount shoud not less than 0")
|
return fmt.Errorf("maxAmount shoud not less than 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.OrderType == "" {
|
|
||||||
s.OrderType = types.OrderTypeLimitMaker
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user