@jmparsons/ccxt
Version:
A JavaScript / Python / PHP cryptocurrency trading library with support for 100+ exchanges
47 lines (35 loc) • 1.52 kB
JavaScript
const ccxt = require ('../../ccxt.js')
const asTable = require ('as-table')
const log = require ('ololog').configure ({ locate: false })
require ('ansicolor').nice
let sleep = (ms) => new Promise (resolve => setTimeout (resolve, ms))
;(async () => {
// instantiate the exchange
let exchange = new ccxt.bittrex ({
"apiKey": "471b47a06c384e81b24072e9a8739064",
"secret": "694025686e9445589787e8ca212b4cff",
})
try {
// fetch account balance from the exchange
let balance = await exchange.fetchBalance ()
// output the result
log (exchange.name.green, 'balance', balance)
} catch (e) {
if (e instanceof ccxt.DDoSProtection || e.message.includes ('ECONNRESET')) {
log.bright.yellow ('[DDoS Protection] ' + e.message)
} else if (e instanceof ccxt.RequestTimeout) {
log.bright.yellow ('[Request Timeout] ' + e.message)
} else if (e instanceof ccxt.AuthenticationError) {
log.bright.yellow ('[Authentication Error] ' + e.message)
} else if (e instanceof ccxt.ExchangeNotAvailable) {
log.bright.yellow ('[Exchange Not Available Error] ' + e.message)
} else if (e instanceof ccxt.ExchangeError) {
log.bright.yellow ('[Exchange Error] ' + e.message)
} else if (e instanceof ccxt.NetworkError) {
log.bright.yellow ('[Network Error] ' + e.message)
} else {
throw e;
}
}
}) ()
;