Skip to content

Commit

Permalink
bittrex cleanup; bittrex fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iquidus committed Jul 20, 2016
1 parent c11d4f6 commit ef7342e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 41 deletions.
55 changes: 27 additions & 28 deletions lib/markets/bittrex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
19 changes: 11 additions & 8 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 7 additions & 5 deletions views/markets/bittrex.jade
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
extends menu

block market_view
script.
console.log('#{marketdata.data}');
.row
.col-md-12
.panel.panel-default
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.