xfunding: fix sync guard

This commit is contained in:
c9s 2023-03-23 13:07:54 +08:00
parent 80c30d15a0
commit 16608619ca
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

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