Skip to content

Commit

Permalink
Merge branch 'master' into feat/amanpuri
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpater authored Aug 17, 2020
2 parents 291b22b + dbdff37 commit a74035a
Show file tree
Hide file tree
Showing 16 changed files with 11,803 additions and 352 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# [3.14.0](https://github.com/coinranking/exchanges/compare/v3.13.0...v3.14.0) (2020-08-14)


### Bug Fixes

* change base and quoteVolume for fylbit driver ([8c26f88](https://github.com/coinranking/exchanges/commit/8c26f88800d5f597e977d2a61fd6460b8212d006))


### Features

* add baseName to Bitcoiva driver ([91833e7](https://github.com/coinranking/exchanges/commit/91833e7fd6ab3e7bb6c9c55965479101c02af233))
* bitcoiva driver ([68fe560](https://github.com/coinranking/exchanges/commit/68fe560a2e24c5f9e9cef8f1bb32d2b664fcd58e))
* flybit driver ([72a3380](https://github.com/coinranking/exchanges/commit/72a33806bd5b2dce76516f37bb6a46bbc9f15cc6))

# [3.13.0](https://github.com/coinranking/exchanges/compare/v3.12.0...v3.13.0) (2020-08-11)


### Features

* **polarity:** use the waves driver ([5f7a7ec](https://github.com/coinranking/exchanges/commit/5f7a7ec19a49f478464ae7101d7668d845bcfb83))
* polarity driver ([ebd0ba0](https://github.com/coinranking/exchanges/commit/ebd0ba09555588f671273acdde55bd662ea541c3))

# [3.12.0](https://github.com/coinranking/exchanges/compare/v3.11.0...v3.12.0) (2020-08-11)


### Features

* ankerswap driver ([68549ab](https://github.com/coinranking/exchanges/commit/68549ab33da852e5a0e1dc4a371c5d63f10e3c51))
* bololex driver ([4df8bb8](https://github.com/coinranking/exchanges/commit/4df8bb873ffd85933874a98e7883a3c9bdb5a5a7))

# [3.11.0](https://github.com/coinranking/exchanges/compare/v3.10.0...v3.11.0) (2020-07-30)


Expand Down
31 changes: 31 additions & 0 deletions drivers/ankerswap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 Ankerswap extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
// get base and quote data for tickers
const { data: tickers } = await request('https://api.ankerswap.com/api/v1/tickers');

return tickers.map((ticker) => new Ticker({
base: ticker.base_currency,
quote: ticker.target_currency,
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.last_price),
baseVolume: parseToFloat(ticker.base_volume),
quoteVolume: parseToFloat(ticker.target_volume),
}));
}
}

module.exports = Ankerswap;
37 changes: 37 additions & 0 deletions drivers/bitcoiva.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 Bitcoiva extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const { pairlist: markets } = await request('https://www.bitcoiva.com/api/tickers');

return Object.keys(markets).map((market) => {
const ticker = markets[market];
// eslint-disable-next-line no-useless-escape
const [base, quote] = market.split('\/');

return new Ticker({
base,
baseName: ticker.base_full_name,
quote,
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.current_price),
open: parseToFloat(ticker.start_price),
baseVolume: parseToFloat(ticker.volume),
});
});
}
}

module.exports = Bitcoiva;
37 changes: 37 additions & 0 deletions drivers/bololex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 Bitcoiva extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const { result: tickers } = await request('https://api.bololex.com/api/prices');

return tickers.map((ticker) => {
const [base, quote] = ticker.symbol.split('/');

return new Ticker({
base,
quote,
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.last),
open: parseToFloat(ticker.open),
bid: parseToFloat(ticker.bid),
ask: parseToFloat(ticker.ask),
baseVolume: parseToFloat(ticker.volume.base),
quoteVolume: parseToFloat(ticker.volume.quote),
});
});
}
}

module.exports = Bitcoiva;
42 changes: 42 additions & 0 deletions drivers/flybit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const Driver = require('../models/driver');
const request = require('../lib/request');
const Ticker = require('../models/ticker');
const { throttleMap, parseToFloat } = require('../lib/utils');
/**
* @memberof Driver
* @augments Driver
*/
class Flybit extends Driver {
/**
* @param {boolean} isMocked Set to true when stored tickers are used
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers(isMocked) {
const markets = await request('https://api.flybit.com/v2/public/market/all');

const tickers = throttleMap(markets, async ({ MARKET: market }) => {
const ticker = await request(`https://api.flybit.com/v2/public/ticker?market=${market}`);
const [quote, base] = market.split('-');

if (!ticker) {
return undefined;
}

return new Ticker({
base,
quote,
high: parseToFloat(ticker.MAX_PRICE),
low: parseToFloat(ticker.MIN_PRICE),
close: parseToFloat(ticker.CLOSING_PRICE),
open: parseToFloat(ticker.OPENING_PRICE),
baseVolume: parseToFloat(ticker.UNITS_TRADED_24H),
quoteVolume: parseToFloat(ticker.ACC_TRADE_VALUE_24H),
});
}, isMocked ? 0 : 50); // 20 requests per second

return Promise.all(tickers);
}
}

module.exports = Flybit;
6 changes: 6 additions & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports.Altcointrader = require('./altcointrader');
exports.Altilly = require('./altilly');
exports.Altmarkets = require('./altmarkets');
exports.Amanpuri = require('./amanpuri');
exports.Ankerswap = require('./ankerswap');
exports.Atomars = require('./atomars');
exports.Bamboo = require('./bamboo');
exports.Bancor = require('./bancor');
Expand All @@ -33,6 +34,7 @@ exports.Bitasset = require('./bitasset');
exports.Bitbank = require('./bitbank');
exports.Bitbay = require('./bitbay');
exports.Bitcoin = require('./bitcoin');
exports.Bitcoiva = require('./bitcoiva');
exports.Bitcratic = require('./bitcratic');
exports.Bitebtc = require('./bitebtc');
exports.Bitfex = require('./bitfex');
Expand Down Expand Up @@ -68,6 +70,7 @@ exports.Bkex = require('./bkex');
exports.Bl3p = require('./bl3p');
exports.Bleutrade = require('./bleutrade');
exports.Blockchain = require('./blockchain');
exports.Bololex = require('./bololex');
exports.Braziliex = require('./braziliex');
exports.Btcalpha = require('./btcalpha');
exports.Btcbox = require('./btcbox');
Expand Down Expand Up @@ -149,6 +152,7 @@ exports.Felixo = require('./felixo');
exports.Finexbox = require('./finexbox');
exports.Fivestar = require('./fivestar');
exports.Floatsv = require('./floatsv');
exports.Flybit = require('./flybit');
exports.Forkdelta = require('./forkdelta');
exports.Ftx = require('./ftx');
exports.Gateio = require('./gateio');
Expand Down Expand Up @@ -217,6 +221,7 @@ exports.Parsxc = require('./parsxc');
exports.Paycml = require('./paycml');
exports.Paymium = require('./paymium');
exports.Payrue = require('./payrue');
exports.Polarity = require('./polarity');
exports.Poloniex = require('./poloniex');
exports.Primebit = require('./primebit');
exports.Prizmbit = require('./prizmbit');
Expand Down Expand Up @@ -264,6 +269,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
82 changes: 82 additions & 0 deletions drivers/polarity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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 Polarity extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const { data: markets } = await request('https://data-service.polarity.exchange/pairs?limit=1000');
const { data: assets } = await request('https://data-service.polarity.exchange/assets?ticker=*');

const currencies = assets.map((asset) => ({
symbol: asset.data.ticker.trim(),
name: asset.data.name,
address: asset.data.id,
}));

// Add Tether manually because polarity.exchange
// didn't include the quote currency in the assets list
currencies.push({
address: '7RB3BWayeCVPq3kkpkeJZAFv2DYCB5gEwnutEpRofaw4',
symbol: 'USDT',
name: 'Tether',
});

return markets.map((market) => {
const baseCurrency = currencies.find((currency) => (market.amountAsset === currency.address));
const quoteCurrency = currencies.find((currency) => (market.priceAsset === currency.address));

let base;
let baseName;
let baseReference;
if (baseCurrency) {
base = baseCurrency.symbol;
baseName = baseCurrency.name;
baseReference = baseCurrency.address;
} else {
base = market.amountAsset;
baseReference = market.amountAsset;
}

let quote;
let quoteName;
let quoteReference;
if (quoteCurrency) {
quote = quoteCurrency.symbol;
quoteName = quoteCurrency.name;
quoteReference = quoteCurrency.address;
} else {
quote = market.priceAsset;
quoteReference = market.priceAsset;
}

const ticker = market.data;

return new Ticker({
base,
baseName,
baseReference,
quote,
quoteName,
quoteReference,
open: parseToFloat(ticker.firstPrice),
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.lastPrice),
vwap: parseToFloat(ticker.weightedAveragePrice),
baseVolume: parseToFloat(ticker.volume),
quoteVolume: parseToFloat(ticker.quoteVolume),
});
});
}
}

module.exports = Polarity;
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 a74035a

Please sign in to comment.