gferrin / bitfinex Goto Github PK
View Code? Open in Web Editor NEWnode.js wrapper for bitfinex cryptocurrency exchange
node.js wrapper for bitfinex cryptocurrency exchange
Is this project MIT licensed?
it appears this function is not implemented in bitfinex.coffee
https://www.bitfinex.com/pages/api
any reason to not include, or is it more a matter of priorities?
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)
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
when orderbook method is called without the optional parameters, the native API is called with limit_bids=50&limit_asks=50.
https://github.com/gferrin/bitfinex/blob/master/src/bitfinex.coffee#L103
account_infos method is not implemented
orderbook method does not support the parameters limit_bids
, limit_asks
and group
parameters.
It is not possible to pass any parameters to orderbook method
line 276
order_id: offer_id
should be
offer_id: offer_id
I have tested OK this change.
Bitfinex API documentation indicates limit_trades
is optional, however the method past_trades
requires it as mandatory parameter
Incorrect URL for ticker
method. As per official Bitfinex API documentation the correct URL is pubticker/
, rather than ticker/
.
Currently the ticker method does not return high
and low
parameters
Now:
https://api.bitfinex.com/v1/ticker/btcusd
With correct URL:
https://api.bitfinex.com/v1/pubticker/btcusd
The method movements
is not implemented
Would it be possible to have mytrades
implemented with options
parameter (only), similar with implementation of orderbook
?
This would also "fix" #14.
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 ?
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
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);
};
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?
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?
promises are so much better than callbacks.
https://github.com/petkaantonov/bluebird
obviously, this should probably be a PR... i just want to make sure it is ok before doing the work.
Are withdraw
and transfer
methods working?
Can't see them in the bitfinex api documentation
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.