pivotshort: market sell to open short

This commit is contained in:
c9s 2022-06-05 12:55:36 +08:00
parent 4bd322feb4
commit 32f324761e
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -303,6 +303,11 @@ 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
lastLow := s.getValidPivotLow(kline.Close)
if lastLow == kline.Close && s.Entry.Immediate {
s.Notify("price breaks the previous low, submitting market sell to open a short position")
s.placeMarketSell(ctx, orderExecutor)
}
})
session.MarketDataStream.OnKLineClosed(func(kline types.KLine) {