mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
fix strategy market data stream usage
This commit is contained in:
parent
4f16f6b1f8
commit
d932a686a0
|
@ -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)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user