From 108bb5deeb68fa21414432e447e2bad66e93b63a Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 23 Mar 2023 22:58:42 +0800 Subject: [PATCH] xfunding: add guard condition for starting and stopping --- pkg/strategy/xfunding/strategy.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/strategy/xfunding/strategy.go b/pkg/strategy/xfunding/strategy.go index 932a97d00..3590564ad 100644 --- a/pkg/strategy/xfunding/strategy.go +++ b/pkg/strategy/xfunding/strategy.go @@ -620,6 +620,10 @@ func (s *Strategy) detectPremiumIndex(premiumIndex *types.PremiumIndex) (changed } func (s *Strategy) startOpeningPosition(pt types.PositionType, t time.Time) { + if s.positionAction == PositionOpening { + return + } + s.positionAction = PositionOpening s.positionType = pt @@ -630,6 +634,10 @@ func (s *Strategy) startOpeningPosition(pt types.PositionType, t time.Time) { } func (s *Strategy) startClosingPosition() { + if s.positionAction == PositionClosing { + return + } + s.positionAction = PositionClosing // reset the transfer stats