pivotshort: add kline event handler and a todo

This commit is contained in:
c9s 2022-06-05 12:48:54 +08:00
parent b20e1335c2
commit e7078edacd
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -300,6 +300,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
}
})
session.MarketDataStream.OnKLine(func(kline types.KLine) {
// TODO: handle stop loss here, faster than closed kline
})
session.MarketDataStream.OnKLineClosed(func(kline types.KLine) {
if kline.Symbol != s.Symbol || kline.Interval != s.Interval {
return
@ -341,7 +345,6 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
limitPrice := s.getValidPivotLow(kline.Close)
log.Infof("%s place limit sell start from %f adds up to %f percent with %d layers of orders", s.Symbol, limitPrice.Float64(), s.Entry.CatBounceRatio.Mul(fixedpoint.NewFromInt(100)).Float64(), s.Entry.NumLayers)
s.placeBounceSellOrders(ctx, s.LastLow, limitPrice, kline.Close, orderExecutor)
// s.placeOrder(ctx, lastLow.Mul(fixedpoint.One.Add(s.CatBounceRatio)), s.Quantity, orderExecutor)
}
})