Skip to content

Commit

Permalink
xfunding: fix sync guard
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Mar 23, 2023
1 parent 80c30d1 commit 1660861
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/strategy/xfunding/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 1660861

Please sign in to comment.