question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MEXC Swap, Error Code: 7002

See original GitHub issue

When trying to create a swap order on MEXC Global exchange, I’m facing an issue where im getting this error code: 7002, with the message “Position mode mis match”

const exchange = new ccxt['mexc']({
  apiKey,
  secret,
});
exchange.options.defaultType = 'swap';
await exchange.createOrder('XRP_USDT', 5, 3, 10, undefined, {
openType: 1, leverage: 15,
})

This is Error Output

{"success":false,"code":7002,"message":"Position mode mis match"} {"name":"ExchangeError","stack":"ExchangeError: mexc {\"success\":false,\"code\":7002,\"message\":\"Position mode mis match\"}\n    at mexc.handleErrors (C:\\Users\\fahad.Hussain\\VS Code Projects\\binance-scraper-bot\\backend\\node_modules\\ccxt\\js\\mexc.js:2316:19)\n    at C:\\Users\\fahad.Hussain\\VS Code Projects\\binance-scraper-bot\\backend\\node_modules\\ccxt\\js\\base\\Exchange.js:716:51\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n    at async timeout (C:\\Users\\fahad.Hussain\\VS Code Projects\\binance-scraper-bot\\backend\\node_modules\\ccxt\\js\\base\\functions\\time.js:203:20)\n    at async mexc.createSwapOrder (C:\\Users\\fahad.Hussain\\VS Code Projects\\binance-scraper-bot\\backend\\node_modules\\ccxt\\js\\mexc.js:1820:26)\n    at async mexc.createOrder (C:\\Users\\fahad.Hussain\\VS Code Projects\\binance-scraper-bot\\backend\\node_modules\\ccxt\\js\\mexc.js:1721:20)\n    at async placeOrder (C:\\Users\\fahad.Hussain\\VS Code Projects\\binance-scraper-bot\\backend\\src\\services\\exchange.service.js:121:19)\n    at async Trader.buy (C:\\Users\\fahad.Hussain\\VS Code Projects\\binance-scraper-bot\\backend\\src\\services\\scraper.service.js:218:27)","timestamp":"2022-03-23 23:56:23"}

This is Verbose output

fetch Request:
 mexc POST https://contract.mexc.com/api/v1/private/order/submit
RequestHeaders:
 {
  ApiKey: 'apiKey',
  'Request-Time': '1648065383488',
  'Content-Type': 'application/json',
  Signature: 'signature'
}
RequestBody:
 {"symbol":"XRP_USDT","vol":10,"side":3,"type":5,"openType":1,"leverage":15}

handleRestResponse:
 mexc POST https://contract.mexc.com/api/v1/private/order/submit 200 OK
ResponseHeaders:
 {
  'Cache-Control': 'max-age=0, no-cache, no-store',
  Connection: 'keep-alive',
  'Content-Encoding': 'gzip',
  'Content-Length': '88',
  'Content-Type': 'application/json',
  Date: 'Wed, 23 Mar 2022 19:56:23 GMT',
  Expires: 'Wed, 23 Mar 2022 19:56:23 GMT',
  Pragma: 'no-cache',
  'Server-Timing': 'cdn-cache; desc=MISS, edge; dur=296, origin; dur=37',
  Vary: 'Accept-Encoding'
}
ResponseBody:
 {"success":false,"code":7002,"message":"Position mode mis match"}

Could you please help out with this bug?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Dan-krmcommented, Mar 24, 2022

Could you please help out with this bug?

I’ve opened a PR that should fix the issue you’re having with createOrder. For mexc you can also call createSwapOrder directly instead of createOrder and it should work properly in the meantime.

1reaction
fahad-herecommented, Mar 29, 2022

Hey @Dan-krm, thanks for the heads up. But it looks like it was due to the position mode on MEXC Global itself.

image

As you can see in the picture attached. When selecting the ‘One-way Mode’ it was giving me the position mismatch error. When I switched to the Hedged mode, it all worked smoothly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

https://support.mexc.com/hc/en-001/articles/360042...
No information is available for this page.
Read more >
MEXC - Bitcoin, Litecoin and Ethereum Exchange and Margin ...
MEXC is a secure and reliable Crypto asset exchange for trading Bitcoin, Ethereum, Litecoin, EOS, TRON, USDT, XRP, etc. MEXC provides various services:...
Read more >
Application error: a client-side exception has occurred - MEXC
MEXC Crypto Exchange. ... Application error: a client-side exception has occurred (see the browser console for more information). © 2022 MEXC.COM.
Read more >
Tutorial for MEXC New-Version Futures - Announcement
Please learn the swap interface carefully. It mainly includes contract information, trading pairs, price information, position and order ...
Read more >
How to Buy TrustSwap (SWAP) Guide - MEXC
Use this guide and you can easily buy TrustSwap (SWAP) with the lowest fees and highest security ... Register via the MEXC website...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found