Skip to content

Commit

Permalink
feat: wenxpro driver
Browse files Browse the repository at this point in the history
  • Loading branch information
sajcics authored and nickpater committed Aug 17, 2020
1 parent 0ca9efc commit dbdff37
Show file tree
Hide file tree
Showing 3 changed files with 4,162 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ exports.Vitex = require('./vitex');
exports.Walkex = require('./walkex');
exports.Wavesexchange = require('./wavesexchange');
exports.Wazirx = require('./wazirx');
exports.Wenxpro = require('./wenxpro');
exports.Whitebit = require('./whitebit');
exports.Wtzex = require('./wtzex');
exports.Xbtpro = require('./xbtpro');
Expand Down
50 changes: 50 additions & 0 deletions drivers/wenxpro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 Wenxpro extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const tickers = await request('https://api.wenxpro.com/openapi/quote/v1/ticker/24hr');
const { symbols } = await request('https://api.wenxpro.com/openapi/v1/brokerInfo');
const pairs = {};

symbols.forEach((el) => {
pairs[el.symbolName] = {
base: el.baseAsset,
baseName: el.baseAssetName,
quote: el.quoteAsset,
quoteName: el.quoteAssetName,
};
});

return tickers.map((ticker) => {
const {
base, quote, baseName, quoteName,
} = pairs[ticker.symbol];

return new Ticker({
base,
baseName,
quote,
quoteName,
high: parseToFloat(ticker.highPrice),
low: parseToFloat(ticker.lowPrice),
close: parseToFloat(ticker.lastPrice),
open: parseToFloat(ticker.openPrice),
baseVolume: parseToFloat(ticker.volume),
quoteVolume: parseToFloat(ticker.quoteVolume),
});
});
}
}

module.exports = Wenxpro;
Loading

0 comments on commit dbdff37

Please sign in to comment.