From 16608619cac4bb48af12e525b25ccce49d357b29 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 23 Mar 2023 13:07:54 +0800 Subject: [PATCH] xfunding: fix sync guard --- pkg/strategy/xfunding/strategy.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/strategy/xfunding/strategy.go b/pkg/strategy/xfunding/strategy.go index 2da6c934c..7f07d6bdf 100644 --- a/pkg/strategy/xfunding/strategy.go +++ b/pkg/strategy/xfunding/strategy.go @@ -374,11 +374,7 @@ func (s *Strategy) reduceFuturesPosition(ctx context.Context) {} // syncFuturesPosition syncs the futures position with the given spot position func (s *Strategy) syncFuturesPosition(ctx context.Context) { - _ = s.futuresOrderExecutor.GracefulCancel(ctx) - - ticker, err := s.futuresSession.Exchange.QueryTicker(ctx, s.Symbol) - if err != nil { - log.WithError(err).Errorf("can not query ticker") + if s.positionType != types.PositionShort { return } @@ -388,7 +384,11 @@ func (s *Strategy) syncFuturesPosition(ctx context.Context) { case PositionOpening, PositionNoOp: } - if s.positionType != types.PositionShort { + _ = s.futuresOrderExecutor.GracefulCancel(ctx) + + ticker, err := s.futuresSession.Exchange.QueryTicker(ctx, s.Symbol) + if err != nil { + log.WithError(err).Errorf("can not query ticker") return }