Skip to content

Commit

Permalink
Merge pull request #1020 from coinranking/feat/add-tokpie-and-xeggex
Browse files Browse the repository at this point in the history
Feat/add tokpie and xeggex
  • Loading branch information
wouthoekstra authored Mar 27, 2024
2 parents b7a6c60 + 654ffa3 commit b14f849
Show file tree
Hide file tree
Showing 5 changed files with 27,089 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ exports.Timex = require('./timex');
exports.Tokenize = require('./tokenize');
exports.Tokens = require('./tokens');
exports.Tokenstore = require('./tokenstore');
exports.Tokpie = require('./tokpie');
exports.Tradeogre = require('./tradeogre');
exports.Traderjoe = require('./traderjoe');
exports.Tradesatoshi = require('./tradesatoshi');
Expand Down Expand Up @@ -222,6 +223,7 @@ exports.Wazirx = require('./wazirx');
exports.Whitebit = require('./whitebit');
exports.Wtzex = require('./wtzex');
exports.Xbts = require('./xbts');
exports.Xeggex = require('./xeggex');
exports.Xt = require('./xt');
exports.Yobit = require('./yobit');
exports.Zb = require('./zb');
Expand Down
47 changes: 47 additions & 0 deletions drivers/tokpie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const Driver = require('../models/driver');
const request = require('../lib/request');
const Ticker = require('../models/ticker');
const { parseToFloat } = require('../lib/utils');

/**
* @memberof Driver
* @augments Driver
*/
class Tokpie extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const markets = await request('https://tokpie.com/api_ticker/');

return Object.keys(markets).flatMap((market) => {
const ticker = markets[market];
if (ticker.isFrozen) return [];

const [base, quote] = ticker.pair.split('@');

const close = parseToFloat(ticker.last);
const baseVolume = parseToFloat(ticker.baseVolume);
const quoteVolume = parseToFloat(ticker.quoteVolume);

if (!close) return [];
if (!baseVolume && !quoteVolume) return [];

return new Ticker({
base,
quote,
open: parseToFloat(ticker.at_first24),
high: parseToFloat(ticker.high24hr),
low: parseToFloat(ticker.low24hr),
close,
bid: parseToFloat(ticker.highestBid),
ask: parseToFloat(ticker.lowestAsk),
baseVolume,
quoteVolume,
});
});
}
}

module.exports = Tokpie;
36 changes: 36 additions & 0 deletions drivers/xeggex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const Driver = require('../models/driver');
const request = require('../lib/request');
const Ticker = require('../models/ticker');
const { parseToFloat } = require('../lib/utils');

/**
* @memberof Driver
* @augments Driver
*/
class Xeggex extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const markets = await request('https://api.xeggex.com/api/v2/tickers');

return Object.keys(markets).flatMap((market) => {
const ticker = markets[market];

return new Ticker({
base: ticker.base_currency,
quote: ticker.target_currency,
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
const: parseToFloat(ticker.last_price),
bid: parseToFloat(ticker.bid),
ask: parseToFloat(ticker.ask),
baseVolume: parseToFloat(ticker.base_volume),
quoteVolume: parseToFloat(ticker.target_volume),
});
});
}
}

module.exports = Xeggex;
Loading

0 comments on commit b14f849

Please sign in to comment.