mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
|
|
|
|
import ccxt from '../../js/ccxt.js';
|
|
import asTable from 'as-table';
|
|
import ansicolor from 'ansicolor';
|
|
import ololog from 'ololog'
|
|
|
|
const log = ololog.configure ({ locate: false })
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
}) () |