pivotshort: avoid market sell again if position is already opened

This commit is contained in:
c9s 2022-06-05 13:13:23 +08:00
parent 629ae39095
commit f883d42c58
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 {
if !found && s.Entry.Immediate && s.Position.IsDust(kline.Close) {
s.Notify("price breaks the previous low, submitting market sell to open a short position")
s.placeMarketSell(ctx, orderExecutor)
}