From e1a9df0a2df201e48ec0511dba020ec2e43fd9d6 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 26 Jun 2022 19:20:30 +0800 Subject: [PATCH] pivotshort: add safety check --- pkg/strategy/pivotshort/protection_stop.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/strategy/pivotshort/protection_stop.go b/pkg/strategy/pivotshort/protection_stop.go index 02a47fac7..ca7553fd5 100644 --- a/pkg/strategy/pivotshort/protection_stop.go +++ b/pkg/strategy/pivotshort/protection_stop.go @@ -168,6 +168,10 @@ func (s *ProtectionStopLoss) handleChange(ctx context.Context, position *types.P } func (s *ProtectionStopLoss) checkStopPrice(closePrice fixedpoint.Value, position *types.Position) { + if s.stopLossPrice.IsZero() { + return + } + if s.shouldStop(closePrice) { log.Infof("[ProtectionStopLoss] protection stop order is triggered at price %f, position = %+v", closePrice.Float64(), position) if err := s.orderExecutor.ClosePosition(context.Background(), one); err != nil {