Skip to content

Commit

Permalink
Merge pull request #216 from coinranking/feat/coindcx
Browse files Browse the repository at this point in the history
feat: coindcx driver
  • Loading branch information
nickpater authored Jul 24, 2020
2 parents 12494f0 + 2ad3c73 commit 57e2988
Show file tree
Hide file tree
Showing 3 changed files with 18,842 additions and 0 deletions.
53 changes: 53 additions & 0 deletions drivers/coindcx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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 Coindcx extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const symbols = await request('https://api.coindcx.com/exchange/v1/markets_details');
const pairs = [];

symbols.forEach((el) => {
pairs[el.symbol] = {
quote: el.base_currency_short_name,
base: el.target_currency_short_name,
quoteName: el.base_currency_name,
baseName: el.target_currency_name,
};
});

const tickers = await request('https://api.coindcx.com/exchange/ticker');

return tickers.map((ticker) => {
if (!pairs[ticker.market]) {
return undefined;
}

const {
base, quote, baseName, quoteName,
} = pairs[ticker.market];

return new Ticker({
base,
baseName,
quote,
quoteName,
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.last_price),
quoteVolume: parseToFloat(ticker.volume),
});
});
}
}

module.exports = Coindcx;
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ exports.Coinbasepro = require('./coinbasepro');
exports.Coinbene = require('./coinbene');
exports.Coinbit = require('./coinbit');
exports.Coincheck = require('./coincheck');
exports.Coindcx = require('./coindcx');
exports.Coindeal = require('./coindeal');
exports.Coineal = require('./coineal');
exports.Coinegg = require('./coinegg');
Expand Down
Loading

0 comments on commit 57e2988

Please sign in to comment.