diff --git a/pkg/bbgo/trader.go b/pkg/bbgo/trader.go index d32c681d9..13b9b699d 100644 --- a/pkg/bbgo/trader.go +++ b/pkg/bbgo/trader.go @@ -24,11 +24,11 @@ type ExchangeSessionSubscriber interface { } type CrossExchangeSessionSubscriber interface { - Subscribe(sessions map[string]*ExchangeSession) + CrossSubscribe(sessions map[string]*ExchangeSession) } type CrossExchangeStrategy interface { - Run(ctx context.Context, orderExecutionRouter OrderExecutionRouter, sessions map[string]*ExchangeSession) error + CrossRun(ctx context.Context, orderExecutionRouter OrderExecutionRouter, sessions map[string]*ExchangeSession) error } //go:generate callbackgen -type Graceful @@ -130,7 +130,7 @@ func (trader *Trader) Run(ctx context.Context) error { for _, strategy := range trader.crossExchangeStrategies { if subscriber, ok := strategy.(CrossExchangeSessionSubscriber); ok { - subscriber.Subscribe(trader.environment.sessions) + subscriber.CrossSubscribe(trader.environment.sessions) } } @@ -250,7 +250,7 @@ func (trader *Trader) Run(ctx context.Context) error { } - if err := strategy.Run(ctx, router, trader.environment.sessions); err != nil { + if err := strategy.CrossRun(ctx, router, trader.environment.sessions); err != nil { return err } } diff --git a/pkg/strategy/movingstop/strategy.go b/pkg/strategy/movingstop/strategy.go index e7330dc0b..08bdf59ea 100644 --- a/pkg/strategy/movingstop/strategy.go +++ b/pkg/strategy/movingstop/strategy.go @@ -63,7 +63,7 @@ type Strategy struct { order types.Order } -func (s *Strategy) Subscribe(sessions map[string]*bbgo.ExchangeSession) { +func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) { sourceSession := sessions[s.SourceExchangeName] sourceSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: s.Interval.String()}) sourceSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: s.MovingAverageInterval.String()}) @@ -136,7 +136,7 @@ func (s *Strategy) handleOrderUpdate(order types.Order) { } } -func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutionRouter, sessions map[string]*bbgo.ExchangeSession) error { +func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, sessions map[string]*bbgo.ExchangeSession) error { // source session sourceSession := sessions[s.SourceExchangeName]