Skip to content

Commit

Permalink
Merge pull request #233 from coinranking/feat/bithumb-pro
Browse files Browse the repository at this point in the history
feat: add support for Bithumb Global
  • Loading branch information
nickpater authored Jul 9, 2020
2 parents d960ea1 + b6eb70b commit 981bf24
Show file tree
Hide file tree
Showing 3 changed files with 7,291 additions and 0 deletions.
46 changes: 46 additions & 0 deletions drivers/Bithumbglobal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const Driver = require('../models/driver');
const request = require('../lib/request');
const Ticker = require('../models/ticker');
const { parseToFloat } = require('../lib/utils.js');

/**
* @memberof Driver
* @augments Driver
*/
class Bithumbglobal extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const { data: { coinConfig: coins } } = await request('https://global-openapi.bithumb.pro/openapi/v1/spot/config');
const { data: tickers } = await request('https://global-openapi.bithumb.pro/openapi/v1/spot/ticker?symbol=ALL');

return tickers.map((ticker) => {
const [base, quote] = ticker.s.split('-');
const baseCoin = coins.find((coin) => coin.name === base);
const quoteCoin = coins.find((coin) => coin.name === quote);

let baseName;
if (baseCoin) baseName = baseCoin.fullName;

let quoteName;
if (quoteCoin) quoteName = quoteCoin.fullName;

return new Ticker({
base,
baseName,
quote,
quoteName,
quoteVolume: parseToFloat(ticker.t),
baseVolume: parseToFloat(ticker.v),
open: parseToFloat(ticker.opening_price),
high: parseToFloat(ticker.h),
low: parseToFloat(ticker.l),
close: parseToFloat(ticker.c),
});
});
}
}

module.exports = Bithumbglobal;
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ exports.Bitfinex = require('./bitfinex');
exports.Bitflyer = require('./bitflyer');
exports.Bitforex = require('./bitforex');
exports.Bithumb = require('./bithumb');
exports.Bithumbglobal = require('./Bithumbglobal');
exports.Bitinfi = require('./bitinfi');
exports.Bitinka = require('./bitinka');
exports.Bitkub = require('./bitkub');
Expand Down
Loading

0 comments on commit 981bf24

Please sign in to comment.