From d38b16fb3e8610809b15eadc6cfe542aad3bfb85 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 2 Dec 2020 22:44:41 +0800 Subject: [PATCH] fix cross exchange strategy subscription --- pkg/bbgo/trader.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/bbgo/trader.go b/pkg/bbgo/trader.go index 5d1c33623..d32c681d9 100644 --- a/pkg/bbgo/trader.go +++ b/pkg/bbgo/trader.go @@ -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 { return err } @@ -224,12 +230,6 @@ func (trader *Trader) Run(ctx context.Context) error { 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 { rs := reflect.ValueOf(strategy) if rs.Elem().Kind() == reflect.Struct {