Skip to content

Instantly share code, notes, and snippets.

@vega113
Created September 29, 2016 07:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vega113/00840178bd8024f4df4eba0e711fde05 to your computer and use it in GitHub Desktop.
Save vega113/00840178bd8024f4df4eba0e711fde05 to your computer and use it in GitHub Desktop.
Check balances in bittrex
var bittrex = require('./node.bittrex.api.js');
bittrex.options({
'apikey': '',
'apisecret': '',
'stream': false,
'verbose': false,
'cleartext': false
});
var total = 0;
function checkRate(tickerData) {
var ticker = {};
ticker.currency = tickerData.Currency;
ticker.balance = tickerData.Balance;
if (tickerData.Currency == "BTC") {
total += tickerData.Balance;
console.log(ticker.currency + ": " + ticker.balance )
console.log("-------total in BTC: " + total + " -------------");
}
else {
var url = "https://bittrex.com/api/v1.1/public/getticker?market=BTC-" + tickerData.Currency;
bittrex.sendCustomRequest(url, function (marketData) {
if (marketData.result == null) {
console.log("no market data for " + tickerData.Currency);
}
var rate = marketData.result.Last;
ticker.btcValue = tickerData.Balance * rate;
total += ticker.btcValue;
console.log(ticker.currency + ": " + ticker.balance + ", rate: " + rate + ", total btc: " + ticker.btcValue)
console.log("-------total in BTC: " + total + " -------------");
});
}
}
bittrex.getbalances(function (data) {
data.result.forEach(function (tickerData) {
if (tickerData.Balance > 0) {
checkRate(tickerData);
}
});
});
@TestniTester
Copy link

where do i get node.bittrex.api.js?*

@akshayjadhav382011
Copy link

where do i get node.bittrex.api.js?*

@lukehaines2
Copy link

FYI this errors out for USDT (marketData.result) - because the market is USDT-BTC, rather than BTC-USDT.
Pretty easy fix though, thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment