ccxt: Poloniex Nonce error

This small code:

import ccxt
poloniex = ccxt.poloniex()
poloniex.apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
poloniex.secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
print(poloniex.private_post_getmarginposition({'currencyPair': 'BTC_XMR'}))
print(poloniex.private_post_returnmarginaccountsummary())
marginbalance = poloniex.private_post_returnmarginaccountsummary()
print(marginbalance['totalValue'])

produce strange error

ccxt.errors.ExchangeNotAvailable: poloniex POST https://poloniex.com/tradingApi 422   {"error":"Nonce must be greater than 1508002069. You provided 1508002069."}`

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (15 by maintainers)

Commits related to this issue

Most upvoted comments

After update, work without sleep(). Brilliance work and support! Thank you!

Igor, you great man! I add sleep (1) before every order operation, and ta da… work correctly 😃

There’s a ton of info on this in the Manual, in other posts linked to this issue above, and in the examples as well.

@mazertwo: the problem is not your keypair, but the frequency of your requests. There should be a pause between them. Poloniex, as well as all other exchanges, won’t let you send your private requests too quickly, all in a split second or in short time. You should make a delay before sending each next private request to stay below rate limit, otherwise you’ll get banned by the exchange.

I’m really frustrated by the fact that you don’t want to read the Manual and prefer asking instead – it will be slower to get an answer from me, than from the Manual. So, if you don’t want to avoid all questions, and instead you want you prefer learning it the hard way, by trying and failing, then asking and retrying again, here’s a quick answer:

If you want ccxt to make a pause for you, do this:

import ccxt
poloniex = ccxt.poloniex()
poloniex.enableRateLimit = True  # ←--------------- this line
poloniex.apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
poloniex.secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
print(poloniex.private_post_getmarginposition({'currencyPair': 'BTC_XMR'}))
print(poloniex.private_post_returnmarginaccountsummary())
marginbalance = poloniex.private_post_returnmarginaccountsummary()
print(marginbalance['totalValue'])

The better way would be to read and understand the Manual entirely from the beginning to the very end. I find it really strange, but how is it at all possible to risk money without even reading the Manual? It wouldn’t take more than one hour of your time. But you will find all very important details there.