mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
simplify strategy registration api
This commit is contained in:
parent
c71f013916
commit
19b600bb35
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
RegisterExchangeStrategy("test", &TestStrategy{})
|
||||
RegisterStrategy("test", &TestStrategy{})
|
||||
}
|
||||
|
||||
type TestStrategy struct {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
bbgo.RegisterExchangeStrategy("buyandhold", &Strategy{})
|
||||
bbgo.RegisterStrategy("buyandhold", &Strategy{})
|
||||
}
|
||||
|
||||
type Strategy struct {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
bbgo.RegisterExchangeStrategy("pricealert", &Strategy{})
|
||||
bbgo.RegisterStrategy("pricealert", &Strategy{})
|
||||
}
|
||||
|
||||
type Strategy struct {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
bbgo.RegisterExchangeStrategy("skeleton", &Strategy{})
|
||||
bbgo.RegisterStrategy("skeleton", &Strategy{})
|
||||
}
|
||||
|
||||
type Strategy struct {
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
bbgo.RegisterExchangeStrategy("swing", &Strategy{})
|
||||
bbgo.RegisterStrategy("swing", &Strategy{})
|
||||
}
|
||||
|
||||
type Strategy struct {
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
bbgo.RegisterExchangeStrategy("xpuremaker", &Strategy{})
|
||||
bbgo.RegisterStrategy("xpuremaker", &Strategy{})
|
||||
}
|
||||
|
||||
type Strategy struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user