Skip to content

Commit

Permalink
fix(indodax): change the url used to fech the tickers
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpater committed Jul 23, 2020
1 parent 4ce44aa commit 8c1b82c
Show file tree
Hide file tree
Showing 2 changed files with 854 additions and 2,177 deletions.
27 changes: 12 additions & 15 deletions drivers/indodax.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,24 @@ class Indodax extends Driver {
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const data = await request('https://indodax.com/api/webdata');
const volumes = Object.values(data.volumes);
const markets = volumes.map((volume) => {
const [quote, base] = Object.keys(volume);
return { base, quote };
});
const { tickers } = await request('https://indodax.com/api/ticker_all');

const markets = Object.keys(tickers);

return markets.map((market) => {
const { base, quote } = market;
const volume = data.volumes[`${base}${quote}`];
const ticker = tickers[market];
const [base, quote] = market.split('_');

return new Ticker({
base,
quote,
baseVolume: parseToFloat(volume[base]),
quoteVolume: parseToFloat(volume[quote]),
close: parseToFloat(data.prices[`${base}${quote}`], (number) => {
// Convert from SATOSHI to btc
if (market.quote === 'btc') number /= 1e8;
return number;
}),
baseVolume: parseToFloat(ticker[`vol_${base}`]),
quoteVolume: parseToFloat(ticker[`vol_${quote}`]),
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.last),
bid: parseToFloat(ticker.buy),
ask: parseToFloat(ticker.sell),
});
});
}
Expand Down
Loading

0 comments on commit 8c1b82c

Please sign in to comment.