GithubHelp home page GithubHelp logo

bitfinex's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitfinex's Issues

Nonce is too small

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 [email protected]?
    @.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

better nonce generation

The current nonce generation could be improved to support more requests per second, the nodejs bitstamp api https://github.com/askmike/bitstamp has a nice implementation:

// if you call new Date to fast it will generate
// the same ms, helper to make sure the nonce is
// truly unique (supports up to 999 calls per ms).
Bitstamp.prototype._generateNonce = function() {
var now = new Date().getTime();

if(now !== this.last)
this.nonceIncr = -1;

this.last = now;
this.nonceIncr++;

// add padding to nonce incr
// @link https://stackoverflow.com/questions/6823592/numbers-in-the-form-of-001
var padding =
this.nonceIncr < 10 ? '000' :
this.nonceIncr < 100 ? '00' :
this.nonceIncr < 1000 ? '0' : '';
return now + padding + this.nonceIncr;
}

Would you use this implementation ?

New Node Wrapper

Hello, I just saw, this project has no recent commits and there seems to be an
official version.
If this project is no longer maintained it should have an entry in the Readme.md

change to new_orders to allow all the options

so if you want to do an oco order, you can get the parameters from the doco and add them in, otherwise pass {} as additional params.

:)

Bitfinex.prototype.new_order = function(symbol, amount, price, exchange, side, type, additional_params, cb) {
var params;
params = {
symbol: symbol,
amount: amount,
price: price,
exchange: exchange,
side: side,
type: type
};
if (typeof additional_params === 'function') {
cb = additional_params;
}else {
for (var key in additional_params) params[key] = additional_params[key];
}
return this.make_request('order/new', params, cb);
};

withdrawls ?!

hey, im testing this bitfinex api,
works great for getting wallet balances...
now im looking and cant find
can i do withdrawls with this api?
like send XRP/BTC from my bitfinex wallet (API) to any other wallet (not on bitfinex)

oh and another thing...
how about show open orders?

is_hidden does not work when value is false

Hi,

When I place orders with "is_hidden = true" all is good, but when "is_hidden = false" I get "Error: Key is_hidden was not present."

For reference, not working request:
{ request: '/v1/order/new',
nonce: '1421955474',
symbol: 'ltcusd',
amount: '0.1',
price: '1.431',
exchange: 'bitfinex',
side: 'sell',
type: 'limit',
is_hidden: false }

Working request:
{ request: '/v1/order/new',
nonce: '1421955044',
symbol: 'ltcusd',
amount: '0.1',
price: '1.431',
exchange: 'bitfinex',
side: 'sell',
type: 'limit',
is_hidden: true }

Is this perhaps an issue at the api?

there is a bug in the bitfinex.js

when I use this code:

bitfinex.new_order("ltcusd", '0.01', '5', "all", "sell", "exchange limit", 
    function(err, res, order_id){
        console.log(err);
        console.log(res);
        console.log(order_id);
});

it has the error:
[Error: Nonce is too small.]
So i modify the code here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.