Skip to content

Commit

Permalink
add GetRegisteredStrategy function
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 5, 2025
1 parent 4150127 commit dd68c82
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/bbgo/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ func SetBackTesting(s *service.BacktestService) {
var LoadedExchangeStrategies = make(map[string]SingleExchangeStrategy)
var LoadedCrossExchangeStrategies = make(map[string]CrossExchangeStrategy)

func GetRegisteredStrategy(id string) (types.StrategyID, error) {
if st, ok := LoadedExchangeStrategies[id]; ok {
return st, nil
}

if st, ok := LoadedCrossExchangeStrategies[id]; ok {
return st, nil
}

return nil, fmt.Errorf("strategy %s is not defined or registered, be sure to call the RegisterStrategy() func", id)
}

func RegisterStrategy(key string, s interface{}) {
loaded := 0
if d, ok := s.(SingleExchangeStrategy); ok {
Expand Down

0 comments on commit dd68c82

Please sign in to comment.