-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added examples/js/bittrex-balance.js
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
}) () |