Skip to content

Commit

Permalink
added examples/js/bittrex-balance.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Nov 30, 2017
1 parent 513aef5 commit 57588d7
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions examples/js/bittrex-balance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";

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;
}
}

}) ()

0 comments on commit 57588d7

Please sign in to comment.