Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

ggetBalance error (4.04) #193

Closed
vincentbollaert opened this issue May 26, 2017 · 67 comments
Closed

ggetBalance error (4.04) #193

vincentbollaert opened this issue May 26, 2017 · 67 comments

Comments

@vincentbollaert
Copy link

vincentbollaert commented May 26, 2017

ggetBalance error:
{ error: 'Nonce must be greater than 149582751298100. You provided 149582751297600.' }

Poloniex API is down! unable to call getBalance, retrying in 10s

While making its 1st purchase on poloniex.BCN-BTC

@DeviaVir
Copy link
Owner

Poloniex API is down!

Did you retry? Are you able to connect to Poloniex (or any internet site) from the box that is running your bot?

@vincentbollaert
Copy link
Author

I wasn't running Zenbot in a docker container, and not sure the API being down is even related. The provided 'nonce' is incorrect

@marcelomurad
Copy link

marcelomurad commented May 28, 2017

Having the same issue here.

Nonce must be greater than xxx

or the time out error bellow.

ggetBalance error:
{ error: 'Connection timed out. Please try again.' }
Poloniex API is down! unable to call getBalance, retrying in 10s

It seens like it does not work only some times. I put a console.log in the end of getBalance function and most of the time it passes. Could it be the number of request per second/minute Poloniex accepts?

@grleblanc
Copy link

grleblanc commented Jun 2, 2017

Also getting this same error:

ggetBalance error:
{ error: 'Nonce must be greater than 1496361634359495. You provided 149636192715100.' }

If you look at the time stamps, they are off by a few orders of 10

Example:
1496361634359495 # Needed
149636192715100 # Provided by Zenbot

@semihalev
Copy link

semihalev commented Jun 8, 2017

Having same issue.

Reference: knowm/XChange#1193

getBalance error:
{ error: 'Nonce must be greater than 149695216646000. You provided 149695215679400.' }

Poloniex API is down! unable to call getBalance, retrying in 10s

getBalance error:
{ error: 'Nonce must be greater than 149695225678600. You provided 149695224643200.' }

Poloniex API is down! unable to call getBalance, retrying in 10s

getBalance error:
{ error: 'Nonce must be greater than 149695230660000. You provided 149695229647500.' }

Poloniex API is down! unable to call getBalance, retrying in 10s

getBalance error:
{ error: 'Nonce must be greater than 149695237659600. You provided 149695236673600.' }

Poloniex API is down! unable to call getBalance, retrying in 10s

@denisa08
Copy link

denisa08 commented Jun 10, 2017

AnnihilaT , it didnt help. I have full default settings. Im trying work with polo in the docker zenbot.

---------------------------- STARTING LIVE TRADING ----------------------------
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705692249700.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705693291700.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705694629500.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705695656400.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705696684000.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705698020600.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705699047800.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705700975900.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705702339800.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705703368000.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705704670000.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705706565900.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705707592600.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705708647000.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705711675200.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705712704600.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705714236500.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705715261200.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705717289200.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705718321400.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705719642600.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705721204200.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705722234000.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705723293500.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705724822400.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 1496885422687535. You provided 149705725911000.' }

#bug #help wanted

@nao0811ta
Copy link

nao0811ta commented Jun 11, 2017

try new generated api key.
and avoid to use multiple application with same key.

https://github.com/codiwest/zenbot/blob/master/docs/FAQ.md#error-1

@denisa08
Copy link

nao0811ta, thanks! All work fine!

@FreshLondon
Copy link

ggetBalance error:
{ error: 'Nonce must be greater than 149724606975500. You provided 149724606975300.' }

Poloniex API is down! unable to call getBalance, retrying in 10s

To combat these errors I have followed steps other users have taken across the web but no success!

  • changed to a new set of API keys.
  • tested on a whole new installation on a different computer (while a friend who trades with me also has tried it on two of his).
  • run system clock updates to verify if its out of sync and to adjust.

None of the above have worked, it's providing the wrong times to Poloniex (and i assume as it's a nonce issue this is not exchange specific).

Any new suggestions, did anyone else find something different that worked here?
Thanks in advance :)

@nao0811ta
Copy link

nao0811ta commented Jun 12, 2017

@CreativeBacon
Hmm..
I suggest modify poloniex/exchange.js to
12 function publicClient (product_id) {
13 // if (!public_client) public_client = new
Poloniex(c.poloniex.key, c.poloniex.secret)
14 // return public_client
15 return authedClient()
16 }

I think the reason is exchange.js's two poloniex instance.
So, another instance have old nonce value.
It need to be thread-safe..

@FreshLondon
Copy link

Thank you for the speedy reply, super appreciated!

I have made the edits as specified and the following error is now presented:
`Alexs-MacBook-Pro:zenbot alex$ zenbot trade --period=1m poloniex.doge-btc
fetching pre-roll data:
/Users/alex/zenbot/node_modules/poloniex.js/lib/poloniex.js:30
this._getPrivateHeaders = function(parameters) {
^

TypeError: Cannot set property '_getPrivateHeaders' of undefined
at Poloniex (/Users/alex/zenbot/node_modules/poloniex.js/lib/poloniex.js:30:33)
at publicClient (/Users/alex/zenbot/extensions/exchanges/poloniex/exchange.js:14:9)
at Object.getTrades (/Users/alex/zenbot/extensions/exchanges/poloniex/exchange.js:57:26)
at getNext (/Users/alex/zenbot/commands/backfill.js:75:22)
at Object. (/Users/alex/zenbot/commands/backfill.js:64:11)
at Immediate. (/Users/alex/zenbot/node_modules/sosa/api.js:15:12)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
Alexs-MacBook-Pro:zenbot alex$
`

@FreshLondon
Copy link

update, the line wrap on your post made me think line 13 was now to be separated.
I have tried and it's running!

I'll update with progress, thanks again. :)

@nao0811ta
Copy link

Period is so short and different line of source with mine.
It works for me with macd strategy and default parameters on up to date version.

@FreshLondon
Copy link

screen shot 2017-06-12 at 15 36 23

as shown in the above screenshot, zenbot shows the attempted buy but then thinks it's succeeded.
The bid is not withdrawn and stays there, I have a pending bid at the currency it tried to buy and zenbot has stopped tracking this buy order due to the nonce error.

@nao0811ta
Copy link

@CreativeBacon
It's only temporary modification.
Due it's not my logic, Someone Let me know better and safe methology..
Or different poloniex library we need

@nao0811ta
Copy link

My logs tracked well.
Which strategy are you using??

@nao0811ta
Copy link

How about retrying modified logic with your new key.

@FreshLondon
Copy link

Still a lot of nonce errors, debugging at present!

How does the bot calculate the nonce?

@tuxitor
Copy link
Contributor

tuxitor commented Jun 12, 2017

@CreativeBacon The nonce generation is not done by the bot. It is done in the API functions from exchange API which is pulled in when you do an "npm install"

@nao0811ta
Copy link

nao0811ta commented Jun 12, 2017

@CreativeBacon
I modified like below.
I'm using two API key lol..

 12   function publicClient (product_id) {
 13     if (!public_client) public_client = new Poloniex(c.poloniex.key, c.poloniex.secret)
 14     return public_client
 15   }
 16 
 17   function authedClient () {
 18     if (!authed_client) {
 19       if (!c.poloniex || !c.poloniex.key || c.poloniex.key === 'YOUR-API-KEY') {
 20         throw new Error('please configure your Poloniex credentials in conf.js')
 21       }
 22       authed_client = new Poloniex(c.poloniex2.key, c.poloniex2.secret)
 23     }
 24     return authed_client
 25   }

@nao0811ta
Copy link

nao0811ta commented Jun 12, 2017

found

getBalance and getTrades are send sometimes at the same time.
I'm using lock flag . but need to handle by mutex

getBalance
finish getBalance
getTrades
finish getTrades
getBalance
locked from getTrades
finish getBalance
2017-06-12 14:18:51  0.13908836 ETH-BTC   -1.1%    21737      +++  +00.0019      74           2.24 ETH  0.00280 BTC   +12.3%  -14.4%

@FreshLondon
Copy link

interesting, I have also added a second set of API keys and will test once they unban me in two minutes!

Nice suggestion.. 👍

@nao0811ta
Copy link

@CreativeBacon
Apparently, two API keys was not good idea.
use lock flag and when locked, retry.
Tentatively
ETH-BTC to the Moon now.

@FreshLondon
Copy link

@nao0811ta
Removed double API. 👍
By 'lock flag' you mean to add --lock to the run command?

This would be easier messaging back and forth on a skype chat, feel free to add me - my Skype ID is freshlondon.biz

@FreshLondon
Copy link

screen shot 2017-06-12 at 23 05 15

not testing with large amounts of course, but if the above image helps..? 😃

@nao0811ta
Copy link

like that

 52     getTrades: function (opts, cb) {
 53 //console.error('getTrades')
 54       var func_args = [].slice.call(arguments)
 55 if (lock) {
 56 //  console.log('locked from getTrades')
 57   return retry('getTrades', func_args)
 58 }
 59 //console.log('getTrades')
 60 lock = true
 61       var client = publicClient()
 62       var args = {
 63         currencyPair: joinProduct(opts.product_id)
 64       }
 65       if (opts.from) {
 66         args.start = opts.from
 67       }
 68       if (opts.to) {
 69         args.end = opts.to
 70       }
 71       if (args.start && !args.end) {
 72         // add 2 hours
 73         args.end = args.start + 7200
 74       }
 75       else if (args.end && !args.start) {
 76         // subtract 2 hours
 77         args.start = args.end - 7200
 78       }
 79 
 80       client._public('returnTradeHistory', args, function (err, body) {
 81 lock = false

@FreshLondon
Copy link

screen shot 2017-06-12 at 23 35 50

i hope i did the above correctly, although i am returned:
screen shot 2017-06-12 at 23 36 46

note how i tried running with both --lock and without in the command, just in case.
I wish this wasn't JS, one of the coding languages i totally suck at! 😒

@crack00r
Copy link

again :(
and more erros

`ggetBalance error:
{ error: 'Nonce must be greater than 149754973633900. You provided 149754972917800.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
ggetBalance error:
{ error: 'Nonce must be greater than 149754973633900. You provided 149754972919100.' }

Poloniex API is down! unable to call getBalance, retrying in 10s

{ Error: unable to sell
at /root/zenbot/extensions/exchanges/poloniex/exchange.js:206:17
at Request._callback (/root/zenbot/node_modules/poloniex.js/lib/poloniex.js:79:7)
at Request.self.callback (/root/zenbot/node_modules/poloniex.js/node_modules/request/request.js:122:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
at Request. (/root/zenbot/node_modules/poloniex.js/node_modules/request/request.js:888:14)
at emitOne (events.js:120:20)
at Request.emit (events.js:210:7)
at IncomingMessage. (/root/zenbot/node_modules/poloniex.js/node_modules/request/request.js:839:12)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1045:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickCallback (internal/process/next_tick.js:161:9)
body: { error: 'Nonce must be greater than 149754975230800. You provided 149754975229100.' },
desc: 'could not execute sell: error placing order' }

ggetBalance error:
{ error: 'Nonce must be greater than 149754975863100. You provided 149754975106300.' }

Poloniex API is down! unable to call getBalance, retrying in 10s
`

@denisa08
Copy link

@crack00r docker-compose build, docker-compose up and after all works fine

@crack00r
Copy link

i use ubuntu

@denisa08
Copy link

@crack00r i see it errors too:( Our patch don't work.

@crack00r
Copy link

someone fix it here
rferro/plnx#2
but i cant implement it

@nao0811ta
Copy link

nao0811ta commented Jun 15, 2017

sorry too late
it's mine it works

var Poloniex = require('poloniex.js')
  , path = require('path')
  , moment = require('moment')
  , n = require('numbro')
  , colors = require('colors')

module.exports = function container (get, set, clear) {
  var c = get('conf')

  var public_client, public_client2, authed_client

  function publicClient (product_id) {
    if (!public_client) public_client = new Poloniex(c.poloniex.key, c.poloniex.secret)
    return public_client
  }

  function authedClient () {
    if (!authed_client) {
      if (!c.poloniex || !c.poloniex.key || c.poloniex.key === 'YOUR-API-KEY') {
        throw new Error('please configure your Poloniex credentials in conf.js')
      }
      authed_client = new Poloniex(c.poloniex.key, c.poloniex.secret)
    }
    return authed_client
  }

  function joinProduct (product_id) {
    return product_id.split('-')[1] + '_' + product_id.split('-')[0]
  }

  function retry (method, args) {
    if (method !== 'getTrades') {
      console.error(('\nPoloniex API is down! unable to call ' + method + ', retrying in 10s').red)
    }
    setTimeout(function () {
      exchange[method].apply(exchange, args)
    }, 10000)
  }

  var orders = {}
  var lock = false
  var exchange = {
    name: 'poloniex',
    historyScan: 'backward',
    makerFee: 0.15,
    takerFee: 0.25,

    getProducts: function () {
      return require('./products.json')
    },

    getTrades: function (opts, cb) {
//console.error('getTrades')
      var func_args = [].slice.call(arguments)
if (lock) {
//  console.log('locked from getTrades')
  return retry('getTrades', func_args)
}
//console.log('getTrades')
lock = true
      var client = publicClient()
      var args = {
        currencyPair: joinProduct(opts.product_id)
      }
      if (opts.from) {
        args.start = opts.from
      }
      if (opts.to) {
        args.end = opts.to
      }
      if (args.start && !args.end) {
        // add 2 hours
        args.end = args.start + 7200
      }
      else if (args.end && !args.start) {
        // subtract 2 hours
        args.start = args.end - 7200
      }

      client._public('returnTradeHistory', args, function (err, body) {
lock = false
//console.log('finish getTrades')
        if (err) return cb(err)
//console.error('getTrades returnTradeHistory')
        if (typeof body === 'string') {
          return retry('getTrades', func_args)
        }
        if (!body.map) {
          console.error('\getTrades odd result:')
          console.error(body)
          return retry('getTrades', func_args)
        }
        var trades = body.map(function (trade) {
          return {
            trade_id: trade.tradeID,
            time: moment.utc(trade.date).valueOf(),
            size: Number(trade.amount),
            price: Number(trade.rate),
            side: trade.type
          }
        })
        cb(null, trades)
      })
    },

    getBalance: function (opts, cb) {
      var args = [].slice.call(arguments)
      var client = authedClient()
if(lock){
// console.error('locked from getBalance')
 return retry('getBalance', args)
}
lock = true
//console.log('getBalance')
      client.returnCompleteBalances(function (err, body) {
lock = false
//console.log('finish getBalance')
        if (err) return cb(err)
//console.error('getBalance returnCompleteBalances')
        var balance = {asset: 0, currency: 0}
        if (typeof body === 'string') {
          return retry('getBalance', args)
        }
        if (body.error) {
          console.error('\ggetBalance error:')
          console.error(body)
          return retry('getBalance', args)
        }
        if (body[opts.currency]) {
          balance.currency = n(body[opts.currency].available).add(body[opts.currency].onOrders).format('0.00000000')
          balance.currency_hold = body[opts.currency].onOrders
        }
        if (body[opts.asset]) {
          balance.asset = n(body[opts.asset].available).add(body[opts.asset].onOrders).format('0.00000000')
          balance.asset_hold = body[opts.asset].onOrders
        }
        cb(null, balance)
      })
    },

    getQuote: function (opts, cb) {
//console.error('getQuote')
      var args = [].slice.call(arguments)
      var client = publicClient()
      var product_id = joinProduct(opts.product_id)
      client.getTicker(function (err, body) {
        if (err) return cb(err)
//console.error('getQuote getTicker')
        if (typeof body === 'string') {
          return retry('getQuote', args)
        }
        if (body.error) {
          console.error('\ggetQuote error:')
          console.error(body)
          return retry('getQuote', args)
        }
        var quote = body[product_id]
        if (!quote) return cb(new Error('no quote for ' + product_id))
        if (quote.isFrozen == '1') console.error('\nwarning: product ' + product_id + ' is frozen')
        cb(null, {
          bid: quote.highestBid,
          ask: quote.lowestAsk,
        })
      })
    },

    cancelOrder: function (opts, cb) {
//console.error('cancelOrder')
      var args = [].slice.call(arguments)
      var client = authedClient()
      client._private('cancelOrder', {orderNumber: opts.order_id}, function (err, result) {
//console.error('cancelOrder2')
        if (typeof result === 'string') {
          return retry('cancelOrder', args)
        }
        if (!err && !result.success) {
          // sometimes the order gets cancelled on the server side for some reason and we get this. ignore that case...
          if (result.error !== 'Invalid order number, or you are not the person who placed the order.') {
            err = new Error('unable to cancel order')
            err.body = result
          }
        }
        cb(err)
      })
    },

    trade: function (type, opts, cb) {
//console.error('trade')
      var args = [].slice.call(arguments)
if(lock)
{
 return retry('trade', args)
}
lock = true
      var client = authedClient()
      var params = {
        currencyPair: joinProduct(opts.product_id),
        rate: opts.price,
        amount: opts.size,
        postOnly: opts.post_only === false ? '0' : '1'
      }
      client._private(type, params, function (err, result) {
//console.error('trade2')
lock = false
        if (typeof result === 'string') {
          return retry('trade', args)
        }
        var order = {
          id: result ? result.orderNumber : null,
          status: 'open',
          price: opts.price,
          size: opts.size,
          post_only: !!opts.post_only,
          created_at: new Date().getTime(),
          filled_size: '0'
        }
        if (result && result.error === 'Unable to place post-only order at this price.') {
          order.status = 'rejected'
          order.reject_reason = 'post only'
          return cb(null, order)
        }
        else if (result && result.error && result.error.match(/^Not enough/)) {
          order.status = 'rejected'
          order.reject_reason = 'balance'
          return cb(null, order)
        }
        if (!err && result.error) {
          err = new Error('unable to ' + type)
          err.body = result
        }
        if (err) return cb(err)
        orders['~' + result.orderNumber] = order
        cb(null, order)
      })
    },

    buy: function (opts, cb) {
      exchange.trade('buy', opts, cb)
    },

    sell: function (opts, cb) {
      exchange.trade('sell', opts, cb)
    },

    getOrder: function (opts, cb) {
//console.error('getOrder')
      var args = [].slice.call(arguments)
      var order = orders['~' + opts.order_id]
      if (!order) return cb(new Error('order not found in cache'))
      var client = authedClient()
      var params = {
        currencyPair: joinProduct(opts.product_id)
      }
      client._private('returnOpenOrders', params, function (err, body) {
        if (err) return cb(err)
//console.error('returnOpenOrders')
        if (typeof body === 'string' || !body) {
          return retry('getOrder', args)
        }
        var active = false
        if (!body.forEach) {
          console.error('\nreturnOpenOrders odd result:')
          console.error(body)
        }
        else {
          body.forEach(function (api_order) {
            if (api_order.orderNumber == opts.order_id) active = true
          })
        }
        if (!active) {
          order.status = 'done'
          order.done_at = new Date().getTime()
          return cb(null, order)
        }
        client.returnOrderTrades(opts.order_id, function (err, body) {
//console.error('returnOrderTrades')
          if (typeof body === 'string' || !body) {
            return retry('getOrder', args)
          }
          if (err || body.error || !body.forEach) return cb(null, order)
          order.filled_size = '0'
          body.forEach(function (trade) {
            order.filled_size = n(order.filled_size).add(trade.amount).format('0.00000000')
          })
          if (n(order.filled_size).value() == n(order.size).value()) {
            order.status = 'done'
            order.done_at = new Date().getTime()
          }
          cb(null, order)
        })
      })
    },

    // return the property used for range querying.
    getCursor: function (trade) {
      return Math.floor((trade.time || trade) / 1000)
    }
  }
  return exchange
}

@crack00r
Copy link

no rly bug, only api down

Poloniex API is down! unable to call getBalance, retrying in 10s

Poloniex API is down! unable to call getBalance, retrying in 10s

@crack00r
Copy link

and again
returnOpenOrders odd result:
{ error: 'Nonce must be greater than 149756185095800. You provided 149756185068600.' }

@nao0811ta
Copy link

Api down is not bug.
Maybe the reason is your request is frequent.
My code is for avoiding noce error from requesting multiple api at the same time.

@nao0811ta
Copy link

My code is not occured since few days before.

@crack00r
Copy link

@crack00r
Copy link

@crack00r
Copy link

and it didnt cancel the orders
http://prntscr.com/fk9slg

so right now, but is useless

@jjngpuri
Copy link

Are you play with the date of you pc? I do a few days ago and make the bot crazy with nonce error! The solution was make a new poloniex key.

@crack00r
Copy link

crack00r commented Jun 16, 2017

works, i set my server time 2min. above the real time...
no Nonce must be greater than anymore
but still Poloniex API is down! unable to call getBalance, retrying in 10s
is there any way to add 2 ore more apikeys?

http://prntscr.com/fke1ch

@tuxitor
Copy link
Contributor

tuxitor commented Jun 16, 2017

@crack00r
It is really no help in advancing your computers time. the only factor the exchange care about is that the nonce has a higher value than the previous one.
The most important factor is to have a stable clock. You can achieve that by using NTP, but that might not help if you have an unstable computer.

Other reasons:

  • the nonce generator that resides in the exchange API may have bug or bad implementation
  • due to the asyncronous nature of a node program, an old nonce can slip through
  • a bug in the exchange software

@jjngpuri
Copy link

due to the asyncronous nature of a node program, an old nonce can slip through

I made some test... that is the problem... the program make 2 even 3 calls to poloniex whitout wait for the first to be resolved.

@ghost
Copy link

ghost commented Jul 3, 2017

Fixed by adding --lock and installing NTP on centos and set to sync every minute with --period=1m
But this does not fix my nonce issue!!!!!

THE EDIT in exchange.js:

  var orders = {}
  var lock = false
  var exchange = {
    name: 'poloniex',
    historyScan: 'backward',
    makerFee: 0.15,
    takerFee: 0.25,

    getProducts: function () {
      return require('./products.json')
    },

    getTrades: function (opts, cb) {
//console.error('getTrades')
      var func_args = [].slice.call(arguments)
if (lock) {
//  console.log('locked from getTrades')
  return retry('getTrades', func_args)
}
//console.log('getTrades')
lock = true
      var client = publicClient()
      var args = {
        currencyPair: joinProduct(opts.product_id)
      }
      if (opts.from) {
        args.start = opts.from
      }
      if (opts.to) {
        args.end = opts.to
      }
      if (args.start && !args.end) {
        // add 2 hours
        args.end = args.start + 7200
      }
      else if (args.end && !args.start) {
        // subtract 2 hours
        args.start = args.end - 7200
      }

      client._public('returnTradeHistory', args, function (err, body) {
lock = false

@ghost
Copy link

ghost commented Jul 3, 2017

You also need to do this instead of running docker, use separate configs for each instance for different coins and API keys. I run 5.

 ./zenbot.sh trade --conf=/zenbot0/conf0.js --period=1m --buy_pct=100 --sell_pct=100 --lock
 ./zenbot.sh trade --conf=/zenbot0/conf1.js --period=1m --buy_pct=100 --sell_pct=100 --lock
 ./zenbot.sh trade --conf=/zenbot0/conf2.js --period=1m --buy_pct=100 --sell_pct=100 --lock
 ./zenbot.sh trade --conf=/zenbot0/conf3.js --period=1m --buy_pct=100 --sell_pct=100 --lock
 ./zenbot.sh trade --conf=/zenbot0/conf4.js --period=1m --buy_pct=100 --sell_pct=100 --lock

But this is still giving the getbalance nonce error? Adjusting the time correctly using ntp seems to help.
Also setting period to 3m seems to help even more.

I guess poloniex has some type of IP-based flood protection.

I have no idea.. Still getting the nonce issue. But atleast now it's only the nonce issue.

UPDATE: 
I read somewhere that nonce is a generated with time, and for some reason poloniex takes 30 seconds to s send market data so I set my clock 30 seconds ahead about and did get some better results. 

@zalaudekr
Copy link

zalaudekr commented Jul 20, 2017

Had following problem with kraken:

Kraken API warning - unable to call trade (Error: Kraken API returned error: API:Invalid nonce), retrying in 0.15s

Increased the nonce window at Kraken API key settings to 360. No problems right now. I think the request takes to long to process and run into this timeout.

With Kraken - check status page https://status.kraken.com/ 👎

Update:
It's no as often as before but still there. Very often if connection to Kraken had a problem
Kraken API warning - unable to call getTrades (Connection between Cloudflare CDN and api.kraken.com failed), retrying in 0.15s
Kraken API warning - unable to call trade (Error: Kraken API returned error: API:Invalid nonce), retrying in 0.15s

@DeviaVir
Copy link
Owner

Looks like a Kraken issue, closing this side of the equation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests