ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.93k stars 7.51k forks source link

Error in nonce number #24065

Closed 89d55d5288 closed 1 week ago

89d55d5288 commented 1 week ago

Operating System

Debian, Windows

Programming Languages

No response

CCXT Version

4.4.21

Description

Good afternoon, everyone!

Please specify why when 2 or more orders are placed sequentially on EXMO, the nonce of one order is replaced by another? LTC_BTC nonce 1729621203456 BCH_BTC nonce 1729621203556 Error open order LTC/BTC on EXMO: exmo {"result":false,"error":"40009: The nonce parameter is less or equal than what was used before \"1729621203556\""}

fetch Request: exmo POST https://api.exmo.me/v1.1/order_create RequestHeaders: {'Content-Type': 'application/x-www-form-urlencoded', 'Key': '’ , 'Sign': '', 'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate'} RequestBody: nonce=1729621203456&pair=LTC_BTC&quantity=0.17765902&price=0.0010411&type=sell

fetch Request: exmo POST https://api.exmo.me/v1.1/order_create RequestHeaders: {'Content-Type': 'application/x-www-form-urlencoded', 'Key': '’ , 'Sign': '', 'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate'} RequestBody: nonce=1729621203556&pair=BCH_BTC&quantity=0.02477615&price=0.00538429&type=sell

fetch Response: exmo POST https://api.exmo.me/v1.1/order_create 200 ResponseHeaders: {'Date': 'Tue, 22 Oct 2024 18:20:03 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT, DELETE', 'Access-Control-Allow-Headers': 'Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Key, Sign', 'Access-Control-Allow-Credentials': 'true', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'CF-Cache-Status': 'DYNAMIC', 'Server': 'cloudflare', 'CF-RAY': '8d6b7fcaff863bbf-WAW'} ResponseBody: {"result":false,"error":"40009: The nonce parameter is less or equal than what was used before \"1729621203556\""}

Error open order LTC/BTC on EXMO: exmo {"result":false,"error":"40009: The nonce parameter is less or equal than what was used before \"1729621203556\""}

Code

  order = await exchange.create_order(symbol, type, side, amount, price, params=params)
carlosmiei commented 1 week ago

Hello @89d55d5288,

Thanks for reporting it.

Is this issue deterministic?

89d55d5288 commented 1 week ago

Hello @89d55d5288,

Thanks for reporting it.

Is this issue deterministic?

Hello @carlosmiei, Thank you for your question.

I can't identify a pattern. It happens intermittently.

Additionally, there is an error. The order is sent to the exchange. The exchange opens the order, but the response comes {‘result’:false, ‘error’: ‘Error 50052: Insufficient funds’}.

fetch Request: exmo POST https://api.exmo.me/v1.1/order_create RequestHeaders: {'Content-Type': 'application/x-www-form-urlencoded', 'Key': '', 'Sign': '', 'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate'} RequestBody: nonce=1729620812789&pair=XRP_ETH&quantity=9.97600274&price=0.00020468&type=sell

fetch Response: exmo POST https://api.exmo.me/v1.1/order_create 200 ResponseHeaders: {'Date': 'Tue, 22 Oct 2024 18:13:32 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT, DELETE', 'Access-Control-Allow-Headers': 'Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Key, Sign', 'Access-Control-Allow-Credentials': 'true', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'CF-Cache-Status': 'DYNAMIC', 'Server': 'cloudflare', 'CF-RAY': '8d6b76402b853558-WAW'} ResponseBody: {"result":false,"error":"Error 50052: Insufficient funds"} This error also occurs when opening only one order. It is also intermittent.

carlosmiei commented 1 week ago

@89d55d5288 Not sure what we can do differently here tbh, because we can't be more granular than milliseconds and I highly doubt that the order X+1 has the same/smaller timestamp/nonce than the order X.

carlosmiei commented 1 week ago

I think this might be an issue on the exchange side

89d55d5288 commented 1 week ago

@carlosmiei I.e., the number is exchanged at the exchange? This sounds logical following the answer received from the exchange. What about the situation with Insufficient funds?

carlosmiei commented 1 week ago

@89d55d5288

I.e., the number is exchanged at the exchange?

That or they're not respecting the order of the requests.

What about the situation with Insufficient funds?

That also seems to be a problem with their engine, ccxt creates request deterministically if you provide the same symbol/type/side/price/amount

89d55d5288 commented 1 week ago

@carlosmiei Thanks for answers