diff --git a/pkg/bbgo/trader.go b/pkg/bbgo/trader.go index e8cbc13ed..57dcca7f4 100644 --- a/pkg/bbgo/trader.go +++ b/pkg/bbgo/trader.go @@ -24,10 +24,15 @@ type SingleExchangeStrategy interface { Run(ctx context.Context, orderExecutor OrderExecutor, session *ExchangeSession) error } +// StrategyInitializer's Initialize method is called before the Subscribe method call. type StrategyInitializer interface { Initialize() error } +type StrategyDefaulter interface { + Defaults() error +} + // ExchangeSessionSubscriber provides an interface for collecting subscriptions from different strategies // Subscribe method will be called before the user data stream connection is created. type ExchangeSessionSubscriber interface { @@ -153,6 +158,12 @@ func (trader *Trader) Subscribe() { for sessionName, strategies := range trader.exchangeStrategies { session := trader.environment.sessions[sessionName] for _, strategy := range strategies { + if defaulter, ok := strategy.(StrategyDefaulter) ; ok { + if err := defaulter.Defaults(); err != nil { + panic(err) + } + } + if initializer, ok := strategy.(StrategyInitializer); ok { if err := initializer.Initialize(); err != nil { panic(err)