Skip to content

Instantly share code, notes, and snippets.

@elmariachi111
Last active January 4, 2018 14:10
Show Gist options
  • Save elmariachi111/d720bc38d2d16dd9a32e76d051ca0a16 to your computer and use it in GitHub Desktop.
Save elmariachi111/d720bc38d2d16dd9a32e76d051ca0a16 to your computer and use it in GitHub Desktop.
Cryptocurrency Exchange tickers using ccxt

Cryptocurrency Exchange tickers using ccxt

queries tickers from various cryptocurrency exchanges. See https://github.com/ccxt/ccxt for all resources

┌───────────────┬───────────────┬───────────────┬──────────────┬───────────────┐
│ Exchange      │ BTC/EUR       │ ETH/EUR       │ LTC/EUR      │ XMR/EUR       │
├───────────────┼───────────────┼───────────────┼──────────────┼───────────────┤
│ coinmarketcap │ 12150.4880623 │ 817.591620461 │ 193.38186035 │ 326.259801595 │
├───────────────┼───────────────┼───────────────┼──────────────┼───────────────┤
│ kraken        │ 12283.8       │ 800           │ 195.31       │ 306.3         │
└───────────────┴───────────────┴───────────────┴──────────────┴───────────────┘
#!/usr/bin/env node
const ccxt = require ('ccxt');
const Table = require('cli-table2');
const _map = require('lodash.map');
const kraken = new ccxt.kraken({ verbose: false });
const coinmarketcap = new ccxt.coinmarketcap({ verbose: false });
(async function() {
const coinmarketcapTicker = await Promise.all([
coinmarketcap.fetchTicker('BTC/EUR'),
coinmarketcap.fetchTicker('ETH/EUR'),
coinmarketcap.fetchTicker('LTC/EUR'),
coinmarketcap.fetchTicker('XMR/EUR')
]);
const krakenTicker = await Promise.all([
kraken.fetchTicker('BTC/EUR'),
kraken.fetchTicker('ETH/EUR'),
kraken.fetchTicker('LTC/EUR'),
kraken.fetchTicker('XMR/EUR')
]);
const table = new Table({
head: ['Exchange','BTC/EUR', 'ETH/EUR', 'LTC/EUR', 'XMR/EUR']
});
table.push(['coinmarketcap'].concat(_map(coinmarketcapTicker,'last')));
table.push(['kraken'].concat(_map(krakenTicker,'last')));
console.log(table.toString());
})();
{
"name": "cryptomarkets",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"ccxt": "^1.10.561",
"cli-table2": "^0.2.0",
"lodash.map": "^4.6.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment