From d932a686a04b51a40bd6e518dd2756533b831fe7 Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 28 May 2021 03:15:29 +0800 Subject: [PATCH] fix strategy market data stream usage --- pkg/strategy/flashcrash/strategy.go | 2 +- pkg/strategy/pricealert/strategy.go | 2 +- pkg/strategy/schedule/strategy.go | 2 +- pkg/strategy/support/strategy.go | 2 +- pkg/strategy/swing/strategy.go | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/strategy/flashcrash/strategy.go b/pkg/strategy/flashcrash/strategy.go index ccfd6c067..b37aeb688 100644 --- a/pkg/strategy/flashcrash/strategy.go +++ b/pkg/strategy/flashcrash/strategy.go @@ -128,7 +128,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se Window: 25, }) - session.UserDataStream.OnKLineClosed(func(kline types.KLine) { + session.MarketDataStream.OnKLineClosed(func(kline types.KLine) { s.updateOrders(orderExecutor, session) }) diff --git a/pkg/strategy/pricealert/strategy.go b/pkg/strategy/pricealert/strategy.go index 8cbfc1d16..d80271cc2 100644 --- a/pkg/strategy/pricealert/strategy.go +++ b/pkg/strategy/pricealert/strategy.go @@ -33,7 +33,7 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { } func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error { - session.UserDataStream.OnKLine(func(kline types.KLine) { + session.MarketDataStream.OnKLine(func(kline types.KLine) { market, ok := session.Market(kline.Symbol) if !ok { return diff --git a/pkg/strategy/schedule/strategy.go b/pkg/strategy/schedule/strategy.go index 26c4ce8e4..e46c449d2 100644 --- a/pkg/strategy/schedule/strategy.go +++ b/pkg/strategy/schedule/strategy.go @@ -128,7 +128,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se } } - session.UserDataStream.OnKLineClosed(func(kline types.KLine) { + session.MarketDataStream.OnKLineClosed(func(kline types.KLine) { if kline.Symbol != s.Symbol { return } diff --git a/pkg/strategy/support/strategy.go b/pkg/strategy/support/strategy.go index 7cde53166..b71d22a4a 100644 --- a/pkg/strategy/support/strategy.go +++ b/pkg/strategy/support/strategy.go @@ -83,7 +83,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se var iw = types.IntervalWindow{Interval: s.Interval, Window: s.MovingAverageWindow} var ema = standardIndicatorSet.EWMA(iw) - session.UserDataStream.OnKLineClosed(func(kline types.KLine) { + session.MarketDataStream.OnKLineClosed(func(kline types.KLine) { // skip k-lines from other symbols if kline.Symbol != s.Symbol { return diff --git a/pkg/strategy/swing/strategy.go b/pkg/strategy/swing/strategy.go index 1da387c69..cba9bd092 100644 --- a/pkg/strategy/swing/strategy.go +++ b/pkg/strategy/swing/strategy.go @@ -102,8 +102,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se } - // session.UserDataStream.OnKLineClosed - session.UserDataStream.OnKLineClosed(func(kline types.KLine) { + session.MarketDataStream.OnKLineClosed(func(kline types.KLine) { // skip k-lines from other symbols if kline.Symbol != s.Symbol { return