aspernaturet
Version:
A library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs
60 lines (40 loc) • 1.42 kB
JavaScript
const ccxt = require ('../../ccxt.js')
const asTable = require ('as-table')
const log = require ('ololog')
require ('ansicolor').nice;
let printSupportedExchanges = function () {
log ('Supported exchanges:', ccxt.exchanges.join (', ').green)
}
let printUsage = function () {
log ('Usage: node', process.argv[1], 'id'.green)
printSupportedExchanges ()
}
let printSymbols = async (id) => {
// check if the exchange is supported by ccxt
let exchangeFound = ccxt.exchanges.indexOf (id) > -1
if (exchangeFound) {
log ('Instantiating', id.green, 'exchange exchange')
// instantiate the exchange by id
let exchange = new ccxt[id] ()
// load all markets from the exchange
let markets = await exchange.loadMarkets ()
// output a list of all market symbols
log (id.green, 'has', exchange.symbols.length, 'symbols:', exchange.symbols.join (', ').yellow)
// make a table of all markets
let table = asTable.configure ({ delimiter: ' | ' }) (Object.values (markets))
log (table)
} else {
log ('Exchange ' + id.red + ' not found')
printSupportedExchanges ()
}
}
(async function main () {
if (process.argv.length > 2) {
let id = process.argv[2]
await printSymbols (id)
} else {
printUsage ()
}
process.exit ()
}) ()
;