remsed
Version:
A JavaScript cryptocurrency trading library with support for fairdesk.com
39 lines (36 loc) • 1.38 kB
JavaScript
const ccxt = require ('./dist/ccxt.cjs');
const ccxtBundle = require ('./dist/ccxt.bundle.cjs');
const log = require ('ololog');
const ansi = require ('ansicolor').nice;
const assert = require ('assert');
// ----------------------------------------------------------------------------
process.on ('uncaughtException', (e) => {
console.log (e, e.stack); process.exit (1);
});
process.on ('unhandledRejection', (e) => {
console.log (e, e.stack); process.exit (1);
});
// ----------------------------------------------------------------------------
// Simple test just to make sure that the CJS code works
const symbol = 'BTC/USDT:USDT';
async function main() {
try {
// test cjs version
const exchange = new ccxt.bybit({});
const ticker = await exchange.fetchTicker(symbol);
assert(ticker !== undefined);
assert(ticker['symbol'] === symbol);
log.bright.green('[CJS Code] OK');
// test cjs bundle version
const exchangeBundle = new ccxtBundle.bybit({});
const tickeBundle = await exchangeBundle.fetchTicker(symbol);
assert(tickeBundle !== undefined);
assert(tickeBundle['symbol'] === symbol);
log.bright.green('[CJS Bundle Code] OK');
process.exit(0);
} catch (e) {
log.bright.red('[CJS Code] Error: ' + e);
process.exit (1);
}
}
main()