diff --git a/pkg/bbgo/config_test.go b/pkg/bbgo/config_test.go index 7e0bdc759..18d5839dd 100644 --- a/pkg/bbgo/config_test.go +++ b/pkg/bbgo/config_test.go @@ -8,7 +8,7 @@ import ( ) func init() { - RegisterExchangeStrategy("test", &TestStrategy{}) + RegisterStrategy("test", &TestStrategy{}) } type TestStrategy struct { diff --git a/pkg/bbgo/environment.go b/pkg/bbgo/environment.go index 79acb67b6..22b11e1db 100644 --- a/pkg/bbgo/environment.go +++ b/pkg/bbgo/environment.go @@ -15,15 +15,16 @@ import ( ) var LoadedExchangeStrategies = make(map[string]SingleExchangeStrategy) - -func RegisterExchangeStrategy(key string, configmap SingleExchangeStrategy) { - LoadedExchangeStrategies[key] = configmap -} - var LoadedCrossExchangeStrategies = make(map[string]CrossExchangeStrategy) -func RegisterCrossExchangeStrategy(key string, configmap CrossExchangeStrategy) { - LoadedCrossExchangeStrategies[key] = configmap +func RegisterStrategy(key string, s interface{}) { + switch d := s.(type) { + case SingleExchangeStrategy: + LoadedExchangeStrategies[key] = d + + case CrossExchangeStrategy: + LoadedCrossExchangeStrategies[key] = d + } } // Environment presents the real exchange data layer diff --git a/pkg/strategy/buyandhold/strategy.go b/pkg/strategy/buyandhold/strategy.go index b824cfbbc..8f72c9cb0 100644 --- a/pkg/strategy/buyandhold/strategy.go +++ b/pkg/strategy/buyandhold/strategy.go @@ -11,7 +11,7 @@ import ( ) func init() { - bbgo.RegisterExchangeStrategy("buyandhold", &Strategy{}) + bbgo.RegisterStrategy("buyandhold", &Strategy{}) } type Strategy struct { diff --git a/pkg/strategy/pricealert/strategy.go b/pkg/strategy/pricealert/strategy.go index a36c62d60..c715a1db6 100644 --- a/pkg/strategy/pricealert/strategy.go +++ b/pkg/strategy/pricealert/strategy.go @@ -9,7 +9,7 @@ import ( ) func init() { - bbgo.RegisterExchangeStrategy("pricealert", &Strategy{}) + bbgo.RegisterStrategy("pricealert", &Strategy{}) } type Strategy struct { diff --git a/pkg/strategy/skeleton/strategy.go b/pkg/strategy/skeleton/strategy.go index 2139aa8b8..c9cbf697c 100644 --- a/pkg/strategy/skeleton/strategy.go +++ b/pkg/strategy/skeleton/strategy.go @@ -10,7 +10,7 @@ import ( ) func init() { - bbgo.RegisterExchangeStrategy("skeleton", &Strategy{}) + bbgo.RegisterStrategy("skeleton", &Strategy{}) } type Strategy struct { diff --git a/pkg/strategy/swing/strategy.go b/pkg/strategy/swing/strategy.go index 5aa0f4be1..3043aaa6a 100644 --- a/pkg/strategy/swing/strategy.go +++ b/pkg/strategy/swing/strategy.go @@ -12,7 +12,7 @@ import ( ) func init() { - bbgo.RegisterExchangeStrategy("swing", &Strategy{}) + bbgo.RegisterStrategy("swing", &Strategy{}) } type Strategy struct { diff --git a/pkg/strategy/xpuremaker/strategy.go b/pkg/strategy/xpuremaker/strategy.go index 89c6c8f90..53f75737f 100644 --- a/pkg/strategy/xpuremaker/strategy.go +++ b/pkg/strategy/xpuremaker/strategy.go @@ -13,7 +13,7 @@ import ( ) func init() { - bbgo.RegisterExchangeStrategy("xpuremaker", &Strategy{}) + bbgo.RegisterStrategy("xpuremaker", &Strategy{}) } type Strategy struct {