fix cross exchange strategy subscription

This commit is contained in:
c9s 2020-12-02 22:44:41 +08:00
parent cd34c2f4e7
commit d38b16fb3e

View File

@ -128,6 +128,12 @@ func (trader *Trader) Run(ctx context.Context) error {
} }
} }
for _, strategy := range trader.crossExchangeStrategies {
if subscriber, ok := strategy.(CrossExchangeSessionSubscriber); ok {
subscriber.Subscribe(trader.environment.sessions)
}
}
if err := trader.environment.Init(ctx); err != nil { if err := trader.environment.Init(ctx); err != nil {
return err return err
} }
@ -224,12 +230,6 @@ func (trader *Trader) Run(ctx context.Context) error {
sessions: trader.environment.sessions, sessions: trader.environment.sessions,
} }
for _, strategy := range trader.crossExchangeStrategies {
if subscriber, ok := strategy.(CrossExchangeSessionSubscriber); ok {
subscriber.Subscribe(trader.environment.sessions)
}
}
for _, strategy := range trader.crossExchangeStrategies { for _, strategy := range trader.crossExchangeStrategies {
rs := reflect.ValueOf(strategy) rs := reflect.ValueOf(strategy)
if rs.Elem().Kind() == reflect.Struct { if rs.Elem().Kind() == reflect.Struct {