pivotshort: also check isClosed

This commit is contained in:
c9s 2022-06-05 13:14:07 +08:00
parent f883d42c58
commit 016ddfd8cd
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -312,7 +312,7 @@ 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
_, found := s.findHigherPivotLow(kline.Close)
if !found && s.Entry.Immediate && s.Position.IsDust(kline.Close) {
if !found && s.Entry.Immediate && (s.Position.IsClosed() || s.Position.IsDust(kline.Close)) {
s.Notify("price breaks the previous low, submitting market sell to open a short position")
s.placeMarketSell(ctx, orderExecutor)
}