mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +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 {
|
||||
Imports []string `json:"imports" yaml:"imports"`
|
||||
|
||||
ExchangeStrategies []SingleExchangeStrategyConfig
|
||||
CrossExchangeStrategies []bbgo.CrossExchangeStrategy
|
||||
|
||||
PnLReporters []PnLReporter `json:"reportPnL"`
|
||||
PnLReporters []PnLReporter `json:"reportPnL" yaml:"reportPnL"`
|
||||
}
|
||||
|
||||
type Stash map[string]interface{}
|
||||
|
@ -118,6 +120,11 @@ func loadReportPnL(config *Config, stash Stash) 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"]
|
||||
if !ok {
|
||||
return nil
|
||||
|
@ -151,6 +158,10 @@ func loadCrossExchangeStrategies(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"]
|
||||
if !ok {
|
||||
return nil
|
||||
|
@ -161,6 +172,7 @@ func loadExchangeStrategies(config *Config, stash Stash) (err error) {
|
|||
return errors.New("expecting list in exchangeStrategies")
|
||||
}
|
||||
|
||||
|
||||
for _, entry := range configList {
|
||||
configStash, ok := entry.(Stash)
|
||||
if !ok {
|
||||
|
@ -176,6 +188,7 @@ func loadExchangeStrategies(config *Config, stash Stash) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
for id, conf := range configStash {
|
||||
// look up the real struct type
|
||||
if st, ok := bbgo.LoadedExchangeStrategies[id]; ok {
|
||||
|
|
Loading…
Reference in New Issue
Block a user