Browse Source

Added getOrderbook implementation for binance

develop
mark-sch 1 year ago
parent
commit
bbb0b0d6ac
3 changed files with 25 additions and 0 deletions
  1. +23
    -0
      exchange/wrappers/binance.js
  2. +1
    -0
      sample-config.js
  3. +1
    -0
      sample-eth.js

+ 23
- 0
exchange/wrappers/binance.js View File

@ -174,6 +174,29 @@ Trader.prototype.getTrades = function(since, callback, descending) {
retry(undefined, fetch, processResults);
};
Trader.prototype.getOrderbook = function(callback) {
const handle = (err, ob) => {
if (err) return callback(err);
var obStats = {};
//_.each(ob.result[this.pair], function(trade) {
//}, this);
if (this.exchange != undefined) obStats.exchange = this.exchange;
obStats.pair = this.asset + this.currency;
let pair = ob;
obStats.asks = pair.asks;
obStats.bids = pair.bids;
callback(undefined, obStats);
};
const reqData = { symbol: this.pair, limit: 1000 }
const fetch = cb => this.binance.depth(reqData, this.handleResponse('getOrderbook', cb, true));
retry(null, fetch, handle);
}
Trader.prototype.getPortfolio = function(callback) {
const setBalance = (err, data) => {
if (err) return callback(err);

+ 1
- 0
sample-config.js View File

@ -18,6 +18,7 @@ config.watch = {
// see https://gekko.wizb.it/docs/introduction/supported_exchanges.html
exchange: 'binance',
currency: 'USDT',
fetchOrderbook: true,
asset: 'ETH',
// You can set your own tickrate (refresh rate).

+ 1
- 0
sample-eth.js View File

@ -20,6 +20,7 @@ config.watch = {
exchange: 'kraken',
currency: 'EUR',
asset: 'ETH',
fetchOrderbook: true,
// You can set your own tickrate (refresh rate).
// If you don't set it, the defaults are 2 sec for

Loading…
Cancel
Save