-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from coinranking/feat/bithumb-pro
feat: add support for Bithumb Global
- Loading branch information
Showing
3 changed files
with
7,291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.