Skip to content

Nonce is too small #25

Description

@360disrupt

main code

interval = setInterval( ()->
  startTime = moment()
  exchanges = trader.getExchanges()
  async.parallel
    # quotes: (next)->
    #   getQuotes exchanges, (err, quotes)->
    #     if err?
    #       clearInterval(interval)
    #       return next err
    #     timeDelta = moment().diff(startTime, 'seconds')
    #     if timeDelta > 10
    #       clearInterval(interval)
    #       return next "Time Delay #{timeDelta} is to big, trading may not be safe!"
    #     else if timeDelta > 2
    #       console.warn "Time Delay is #{timeDelta} seconds! Please check Latency!"
    #     else if timeDelta > 0
    #       console.info "Time Delay is #{timeDelta} seconds"
    #     return next null, quotes

    balances: (next)->
      getBalances exchanges, (err, balances)->
        if err?
          clearInterval(interval)
          return next err

        return next null

    (err, results)->
      return callback err if err?
      inspect results

, bitcoinTradingConfig.gapSec * 1000)

Bitfinex class

inspect = require('eyespect').inspector({maxLength: null})
chalk = require('chalk')

Bitcoin = require('./bitcoin.class.js')
BitfinexApi = require('bitfinex')
restSenderService = require('../rest-sender.service.js')

class Bitfinex extends Bitcoin
  constructor: (options)->
    super(options)
    if options.apiKey? && options.apiSecret?
      @.bitfinexApi = new BitfinexApi(options.apiKey, options.apiSecret)
    return


  filterQuote: (response)->
    filter = {'bid':'bid', 'ask':'ask'} #1st name on exchange, 2nd label here
    filteredResponse = {}
    for key, value of filter
      filteredResponse[value] = response[key] if response[key]?
    return filteredResponse

  getQuote: (callback)->
    self = @
    @.bitfinexApi.ticker 'btcusd', (err, response)->
      return callback err if err?
      filteredQuote = self.filterQuote response
      return callback null, filteredQuote

  getAvailableBalance: (callback)->
    self = @
    return 0 if !@.bitfinexApi?
    @.bitfinexApi.wallet_balances  (err, response)->
      return callback err if err?
      inspect response
      return callback null, response

#/////////////////////////////////////////////////////////////////////////////////////////////////////
module.exports = Bitfinex

I only have one process running. The Api is currently queried every 3s and there are (at the moment) no other queries in async.parallel.

I get on the first API call of wallet_balances the err Nonce is too small

I even get this, when I move all out of the class and the interval function, e.g.

  BitfinexApi = require('bitfinex')
  bitfinexApi = new BitfinexApi(bitcoinTradingConfig['bitfinex'].apiKey, bitcoinTradingConfig['bitfinex'].apiSecret)
  console.log "TEST>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
  bitfinexApi.wallet_balances  (err, response)->
    console.log err, response

Node v: 6.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions