mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
check runtime registered strategies
This commit is contained in:
parent
6e033461bb
commit
407db84689
|
@ -57,10 +57,12 @@ type PnLReporter struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Imports []string `json:"imports" yaml:"imports"`
|
||||||
|
|
||||||
ExchangeStrategies []SingleExchangeStrategyConfig
|
ExchangeStrategies []SingleExchangeStrategyConfig
|
||||||
CrossExchangeStrategies []bbgo.CrossExchangeStrategy
|
CrossExchangeStrategies []bbgo.CrossExchangeStrategy
|
||||||
|
|
||||||
PnLReporters []PnLReporter `json:"reportPnL"`
|
PnLReporters []PnLReporter `json:"reportPnL" yaml:"reportPnL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stash map[string]interface{}
|
type Stash map[string]interface{}
|
||||||
|
@ -118,6 +120,11 @@ func loadReportPnL(config *Config, stash Stash) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadCrossExchangeStrategies(config *Config, stash Stash) (err error) {
|
func loadCrossExchangeStrategies(config *Config, stash Stash) (err error) {
|
||||||
|
if len(bbgo.LoadedCrossExchangeStrategies) == 0 {
|
||||||
|
return errors.New("no cross exchange strategy is registered")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
exchangeStrategiesConf, ok := stash["crossExchangeStrategies"]
|
exchangeStrategiesConf, ok := stash["crossExchangeStrategies"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
@ -151,6 +158,10 @@ func loadCrossExchangeStrategies(config *Config, stash Stash) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadExchangeStrategies(config *Config, stash Stash) (err error) {
|
func loadExchangeStrategies(config *Config, stash Stash) (err error) {
|
||||||
|
if len(bbgo.LoadedExchangeStrategies) == 0 {
|
||||||
|
return errors.New("no exchange strategy is registered")
|
||||||
|
}
|
||||||
|
|
||||||
exchangeStrategiesConf, ok := stash["exchangeStrategies"]
|
exchangeStrategiesConf, ok := stash["exchangeStrategies"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
@ -161,6 +172,7 @@ func loadExchangeStrategies(config *Config, stash Stash) (err error) {
|
||||||
return errors.New("expecting list in exchangeStrategies")
|
return errors.New("expecting list in exchangeStrategies")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for _, entry := range configList {
|
for _, entry := range configList {
|
||||||
configStash, ok := entry.(Stash)
|
configStash, ok := entry.(Stash)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -176,6 +188,7 @@ func loadExchangeStrategies(config *Config, stash Stash) (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for id, conf := range configStash {
|
for id, conf := range configStash {
|
||||||
// look up the real struct type
|
// look up the real struct type
|
||||||
if st, ok := bbgo.LoadedExchangeStrategies[id]; ok {
|
if st, ok := bbgo.LoadedExchangeStrategies[id]; ok {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user