Permalink
Browse files

bittrex cleanup; bittrex fix

  • Loading branch information...
iquidus committed Jul 20, 2016
1 parent c11d4f6 commit ef7342e19ba7f467c87f3ffd74f21b1c1e671f0a
Showing with 45 additions and 41 deletions.
  1. +27 −28 lib/markets/bittrex.js
  2. +11 −8 routes/index.js
  3. +7 −5 views/markets/bittrex.jade
View
@@ -36,36 +36,35 @@ function get_orders(coin, exchange, cb) {
var orders = body.result;
var buys = [];
var sells = [];
if (orders['buy'].length > 0){
for (var i = 0; i < orders['buy'].length; i++) {
var order = {
amount: parseFloat(orders.buy[i].Quantity).toFixed(8),
price: parseFloat(orders.buy[i].Rate).toFixed(8),
// total: parseFloat(orders.buy[i].Total).toFixed(8)
// Necessary because API will return 0.00 for small volume transactions
total: (parseFloat(orders.buy[i].Quantity).toFixed(8) * parseFloat(orders.buy[i].Rate)).toFixed(8)
}
buys.push(order);
}
} else {}
if (orders['sell'].length > 0) {
for (var x = 0; x < orders['sell'].length; x++) {
var order = {
amount: parseFloat(orders.sell[x].Quantity).toFixed(8),
price: parseFloat(orders.sell[x].Rate).toFixed(8),
// total: parseFloat(orders.sell[x].Total).toFixed(8)
// Necessary because API will return 0.00 for small volume transactions
total: (parseFloat(orders.sell[x].Quantity).toFixed(8) * parseFloat(orders.sell[x].Rate)).toFixed(8)
}
sells.push(order);
}
} else {
if (orders['buy'].length > 0){
for (var i = 0; i < orders['buy'].length; i++) {
var order = {
amount: parseFloat(orders.buy[i].Quantity).toFixed(8),
price: parseFloat(orders.buy[i].Rate).toFixed(8),
// total: parseFloat(orders.buy[i].Total).toFixed(8)
// Necessary because API will return 0.00 for small volume transactions
total: (parseFloat(orders.buy[i].Quantity).toFixed(8) * parseFloat(orders.buy[i].Rate)).toFixed(8)
}
return cb(null, buys, sells);
} else {
return cb(body.message, [], [])
buys.push(order);
}
}
if (orders['sell'].length > 0) {
for (var x = 0; x < orders['sell'].length; x++) {
var order = {
amount: parseFloat(orders.sell[x].Quantity).toFixed(8),
price: parseFloat(orders.sell[x].Rate).toFixed(8),
// total: parseFloat(orders.sell[x].Total).toFixed(8)
// Necessary because API will return 0.00 for small volume transactions
total: (parseFloat(orders.sell[x].Quantity).toFixed(8) * parseFloat(orders.sell[x].Rate)).toFixed(8)
}
sells.push(order);
}
});
}
return cb(null, buys, sells);
} else {
return cb(body.message, [], []);
}
});
}
module.exports = {
View
@@ -131,18 +131,21 @@ router.get('/info', function(req, res) {
});
router.get('/markets/:market', function(req, res) {
var market = req.param('market');
var market = req.params['market'];
if (settings.markets.enabled.indexOf(market) != -1) {
db.get_market(market, function(data) {
var market_data = {
coin: settings.markets.coin,
exchange: settings.markets.exchange,
data: data,
};
/*if (market === 'bittrex') {
data = JSON.parse(data);
}*/
console.log(data);
res.render('./markets/' + market, {
active: 'markets',
marketdata: market_data,
market: market,
marketdata: {
coin: settings.markets.coin,
exchange: settings.markets.exchange,
data: data,
},
market: market
});
});
} else {
View
@@ -1,6 +1,8 @@
extends menu
block market_view
script.
console.log('#{marketdata.data}');
.row
.col-md-12
.panel.panel-default
@@ -48,9 +50,9 @@ block market_view
each buy in marketdata.data.buys
tr
td
=buy.price.toFixed(8)
=buy.price
td
=buy.amount.toFixed(8)
=buy.amount
td.hidden-xs
=buy.total
.col-md-6.col-xs-12
@@ -67,9 +69,9 @@ block market_view
each sell in marketdata.data.sells
tr
td
=sell.price.toFixed(8)
=sell.price
td
=sell.amount.toFixed(8)
=sell.amount
td.hidden-xs
=sell.total
.row
@@ -111,4 +113,4 @@ block market_view
=order.Total.toFixed(8)
td.hidden-xs
=order.TimeStamp
.footer-padding
.footer-padding

0 comments on commit ef7342e

Please sign in to comment.