zenbot
zenbot copied to clipboard
Nonce must be greater than x you provided y
System information
- Have I written custom code (as opposed to using zenbot vanilla): Vanilla
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
- Zenbot version: Master from yesterday
- NodeJS version: Recommend by guide, so 8.X
- Python version: "2.7
- Exact command to reproduce: zenbot.sh trade poloniex.LTC-USDT
Describe the problem
Receiving the following error when live trading. { error: 'Nonce must be greater than 151542773919200. You provided 151542773906900.' }
I've search in older issues and found several suggestions, e.g. new API key, etc, however, none of them solved my issue, and because of that, I'm not able to sell and buy.
Thanks in advance.
Just received it again.. i've also setup NTC without any improvement.
Update: tried to setup a SC-BTC bot which actually trade and has no errors. LTC-USDT continues to do though. Edit: SC-BTC also reports same error now... A STR-USDT bot also returns the same error. getBalance error: { error: 'Nonce must be greater than 151544307345200. You provided 151544307236600.' }
What could be the cause? Edit, i've read the FAQ. No, I'm not using the same API key for all bots, I'm using an unique key for each bot.
Update, for fun I tried to create everything on my remote server at scaleway, same error occurs.
@Gudui I see this on poloniex too. I think the issue is that zenbot makes two instances of the poloniex API connection here: https://github.com/DeviaVir/zenbot/blob/unstable/extensions/exchanges/poloniex/exchange.js#L22
and here: https://github.com/DeviaVir/zenbot/blob/unstable/extensions/exchanges/poloniex/exchange.js#L13
Specifically, the problem isn't two instances, but two instances using the same API key. I've seen other systems use two API keys for poloniex, one for querying public APIs and the other for the private calls. Curious if this might fix this issue for good with zenbot too.
@tiagosiebler Sounds very interesting, nice spotted!
Update @DeviaVir I've made a bugfix and recompiled. I'll let you know and create a PR if it solves the issue.
@DeviaVir my fix by using the public_client variable for both calls, didn't work.. I cannot resolve this :).
@Gudui try creating a second API key & secret in polo, then use that in the conf.js, e.g c.poloniex.key2 & c.poloniex.secret2.
Lastly, edit the second instance to use the c.poloniex.key2 & c.poloniex.secret2 respectively: https://github.com/DeviaVir/zenbot/blob/unstable/extensions/exchanges/poloniex/exchange.js#L22
Can't try it out right now, but that's the idea I meant behind getting this fixed. This way the bot will use a different API key for the public and the private clients, avoiding what I think is causing an overlap in request timings.
@tiagosiebler I'll recompile and try :-).
Hi @tiagosiebler ,
I experience the same issue and I tried your suggestion but doesn't seem to fix the issue. I didn't see it for about 6 hours and out of a sudden it pops up a few times per hour.
Is it possible that it has something to do with the responsiveness of the Poloniex server itself? Maybe we didn't receive a response from the previous request while we are sending the next request? Just throwing out an idea...
Greetings, Frederic
@tiagosiebler and @DeviaVir It does not fix it as @FredericMa mentioned. Still getting the error
I had this problem, and finally resolved it writing this code. It triggers the error, plucks the necessary nonce out of the error message, adds unix epoc time to it for good measure, and sets the new nonce. It's not pretty but it's solid. Note - this is for Python3.x .
For safety you can call set_nonce() prior to executing any sell/buy. So far this has been bullet-proof for me.
import sys
import time
import traceback
import itertools
import poloniex
from poloniex import Poloniex
polo = Poloniex(MY_KEY_XXX, MY_SECRET_XXX)
def say_exception() :
exc_type, exc_value, exc_traceback = sys.exc_info()
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
return ''.join('!! ' + line for line in lines)
def set_nonce():
try :
polo.returnBalances() # forces a failure. We pluck out the necessary nonce from the error msg
except :
reason = say_exception()
phrase = 'Nonce must be greater than'
pos = reason.find(phrase)
if pos > 0 :
rest = reason[pos+len(phrase):]
num = int(rest.split('.')[0])
polo.nonce_iter=itertools.count(num + int(time.time()))
print ('Poloniex nonce set to ' + str(polo.nonce_iter))
#-----------
set_nonce() # You're free to trade!
I change nonce function and work for me.
Install microtime package
npm install microtime
#Change the file "node_modules/poloniex.js/lib/poloniex.js"
this code // Module dependencies var crypto = require('crypto'), request = require('request'), nonce = require('nonce')();
for this code // Module dependencies var crypto = require('crypto'), request = require('request'), nonce = require('microtime');
this code parameters || (parameters = {}); parameters.command = command; parameters.nonce = nonce();
for this code parameters || (parameters = {}); parameters.command = command; parameters.nonce = nonce.now()