Skip to content

fix(mexc): omit reduceOnly in non-hedged swap order branch#28414

Merged
carlosmiei merged 2 commits intoccxt:masterfrom
ToRvaLDz:fix/mexc-hedge-mode-reduceonly
Apr 15, 2026
Merged

fix(mexc): omit reduceOnly in non-hedged swap order branch#28414
carlosmiei merged 2 commits intoccxt:masterfrom
ToRvaLDz:fix/mexc-hedge-mode-reduceonly

Conversation

@ToRvaLDz
Copy link
Copy Markdown
Contributor

Fixes #28410

MEXC swap orders with reduceOnly=true in non-hedged mode include reduceOnly in the HTTP request body. MEXC rejects this parameter, causing order ID collisions with existing open positions in production. The hedged branch already calls this.omit(params, 'reduceOnly') at line ~2558; this PR mirrors that pattern in the non-hedged else-branch.

Only ts/src/mexc.ts is modified (one line added). Two static request tests are added in ts/src/test/static/request/mexc.json verifying that the reduceOnly field is absent from the serialized request body for both buy (side=2) and sell (side=4) close orders.

Note: a separate Bug B (side inversion in the hedged+reduceOnly branch) is under investigation and will be filed as its own issue if confirmed — it is explicitly out of scope for this PR per the ccxt atomic-PR policy.

In hedge mode disabled (non-hedged), when reduceOnly=true, the sideInteger
was correctly set to 2 (buy) or 4 (sell), but reduceOnly was not removed
from params before the final this.extend(request, params) call, causing
reduceOnly to leak into the HTTP request body and trigger id collision
with open orders on MEXC futures.

Add: params = this.omit (params, 'reduceOnly') inside the non-hedged
if (reduceOnly) block, mirroring the existing omit call in the hedged branch.
…SwapOrder

Add two static request test entries verifying that when reduceOnly=true
in non-hedged mode, the HTTP request body contains the correct sideInteger
(2 for buy, 4 for sell) and does NOT include reduceOnly.

These tests fail without the fix in createSwapOrder and pass with it,
providing regression coverage for Bug A.
@carlosmiei carlosmiei self-assigned this Apr 15, 2026
@carlosmiei carlosmiei merged commit 695b440 into ccxt:master Apr 15, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mexc): reduceOnly not removed from request body in non-hedged swap order

2 participants