fix strategy market data stream usage

This commit is contained in:
c9s 2021-05-28 03:15:29 +08:00
parent 4f16f6b1f8
commit d932a686a0
5 changed files with 5 additions and 6 deletions

View File

@ -128,7 +128,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
Window: 25, Window: 25,
}) })
session.UserDataStream.OnKLineClosed(func(kline types.KLine) { session.MarketDataStream.OnKLineClosed(func(kline types.KLine) {
s.updateOrders(orderExecutor, session) s.updateOrders(orderExecutor, session)
}) })

View File

@ -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 { 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) market, ok := session.Market(kline.Symbol)
if !ok { if !ok {
return return

View File

@ -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 { if kline.Symbol != s.Symbol {
return return
} }

View File

@ -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 iw = types.IntervalWindow{Interval: s.Interval, Window: s.MovingAverageWindow}
var ema = standardIndicatorSet.EWMA(iw) 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 // skip k-lines from other symbols
if kline.Symbol != s.Symbol { if kline.Symbol != s.Symbol {
return return

View File

@ -102,8 +102,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
} }
// session.UserDataStream.OnKLineClosed session.MarketDataStream.OnKLineClosed(func(kline types.KLine) {
session.UserDataStream.OnKLineClosed(func(kline types.KLine) {
// skip k-lines from other symbols // skip k-lines from other symbols
if kline.Symbol != s.Symbol { if kline.Symbol != s.Symbol {
return return