forked from iquidus/explorer
-
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.
- Loading branch information
1 parent
1319996
commit cf0ad6d
Showing
6 changed files
with
211 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -30,3 +30,5 @@ settings.json | |
#*.ico | ||
#*.png | ||
|
||
.DS_Store | ||
|
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
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
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,91 @@ | ||
var request = require('request'); | ||
|
||
var base_url = 'https://altmarkets.io/api/v2/'; | ||
|
||
function get_summary(coin, exchange, cb) { | ||
var req_url = base_url + 'tickers/' + coin.toLowerCase() + exchange.toLowerCase(); | ||
var summary = {}; | ||
request({uri: req_url, json: true}, function (error, response, body) { | ||
if (error) { | ||
return cb(error, null); | ||
} else { | ||
if (body.error) { | ||
return cb(body.error, null) | ||
} else { | ||
summary['bid'] = parseFloat(body['ticker']['buy']).toFixed(8); | ||
summary['ask'] = parseFloat(body['ticker']['sell']).toFixed(8); | ||
summary['volume'] = body['ticker']['vol']; | ||
summary['volume_btc'] = body['ticker']['quotevol']; | ||
summary['high'] = body['ticker']['high']; | ||
summary['low'] = body['ticker']['low']; | ||
summary['last'] = body['ticker']['last']; | ||
return cb(null, summary); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
function get_trades(coin, exchange, cb) { | ||
var req_url = base_url + "trades?market=" + coin.toLowerCase() + "" + exchange.toLowerCase() + "&limit=50&order_by=desc"; | ||
request({uri: req_url, json: true}, function (error, response, body) { | ||
if (body.error) { | ||
return cb(body.error, null); | ||
} else { | ||
return cb (null, body); | ||
} | ||
}); | ||
} | ||
|
||
function get_orders(coin, exchange, cb) { | ||
var req_url = base_url + 'depth?market=' + coin.toLowerCase() + exchange.toLowerCase(); | ||
request({uri: req_url, json: true}, function (error, response, body) { | ||
if (body.error) { | ||
return cb(body.error, [], []) | ||
} else { | ||
var orders = body; | ||
var buys = []; | ||
var sells = []; | ||
if (orders['bids'].length > 0){ | ||
for (var i = 0; i < orders['bids'].length; i++) { | ||
var order = { | ||
amount: parseFloat(orders.bids[i][1]).toFixed(8), | ||
price: parseFloat(orders.bids[i][0]).toFixed(8), | ||
// total: parseFloat(orders.bids[i].Total).toFixed(8) | ||
// Necessary because API will return 0.00 for small volume transactions | ||
total: (parseFloat(orders.bids[i][1]).toFixed(8) * parseFloat(orders.bids[i][0])).toFixed(8) | ||
} | ||
buys.push(order); | ||
} | ||
} else {} | ||
if (orders['asks'].length > 0) { | ||
for (var x = 0; x < orders['asks'].length; x++) { | ||
var order = { | ||
amount: parseFloat(orders.asks[x][1]).toFixed(8), | ||
price: parseFloat(orders.asks[x][0]).toFixed(8), | ||
// total: parseFloat(orders.asks[x].Total).toFixed(8) | ||
// Necessary because API will return 0.00 for small volume transactions | ||
total: (parseFloat(orders.asks[x][1]).toFixed(8) * parseFloat(orders.asks[x][0])).toFixed(8) | ||
} | ||
sells.push(order); | ||
} | ||
} else {} | ||
return cb(null, buys, sells); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = { | ||
get_data: function(coin, exchange, cb) { | ||
var error = null; | ||
get_orders(coin, exchange, function(err, buys, sells) { | ||
if (err) { error = err; } | ||
get_trades(coin, exchange, function(err, trades) { | ||
if (err) { error = err; } | ||
get_summary(coin, exchange, function(err, stats) { | ||
if (err) { error = err; } | ||
return cb(error, {buys: buys, sells: sells, chartdata: [], trades: trades, stats: stats}); | ||
}); | ||
}); | ||
}); | ||
} | ||
}; |
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
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,109 @@ | ||
extends menu | ||
|
||
block market_view | ||
.row | ||
.col-md-12 | ||
.panel.panel-default | ||
.panel-heading | ||
strong #{settings.locale.altmarkets} - #{marketdata.coin}/#{marketdata.exchange} - #{settings.locale.mkt_hours} | ||
a(href='#') | ||
span.fa.fa-line-chart.pull-right.view-chart-disabled.iquidus.market-toggle(data-toggle='tooltip', data-placement='bottom', title='#{settings.locale.mkt_no_chart}') | ||
table.table.table-bordered.summary-table | ||
thead | ||
tr | ||
th #{settings.locale.mkt_high} | ||
th #{settings.locale.mkt_low} | ||
th #{settings.locale.mkt_volume} | ||
th.hidden-xs #{settings.locale.mkt_top_bid} | ||
th.hidden-xs #{settings.locale.mkt_top_ask} | ||
th.hidden-xs #{settings.locale.mkt_last} | ||
tbody | ||
tr | ||
td #{marketdata.data.summary.high} | ||
td #{marketdata.data.summary.low} | ||
td #{marketdata.data.summary.volume} | ||
td.hidden-xs #{marketdata.data.summary.bid} | ||
td.hidden-xs #{marketdata.data.summary.ask} | ||
td.hidden-xs #{marketdata.data.summary.last} | ||
.row | ||
.col-md-6.col-xs-12 | ||
.panel.panel-default | ||
.panel-heading | ||
h3.panel-title #{settings.locale.mkt_buy_orders} | ||
table.table.table-striped.table-bordered.order-table | ||
thead | ||
tr | ||
th #{settings.locale.mkt_price} (#{marketdata.exchange}) | ||
th #{settings.locale.mkt_amount} (#{marketdata.coin}) | ||
th.hidden-xs #{settings.locale.mkt_total} (#{marketdata.exchange}) | ||
tbody | ||
each buy in marketdata.data.buys | ||
tr | ||
td | ||
=buy.price | ||
td | ||
=buy.amount | ||
td.hidden-xs | ||
=buy.total | ||
|
||
.col-md-6.col-xs-12 | ||
.panel.panel-default | ||
.panel-heading | ||
h3.panel-title #{settings.locale.mkt_sell_orders} | ||
table.table.table-striped.table-bordered.order-table | ||
thead | ||
tr | ||
th #{settings.locale.mkt_price} (#{marketdata.exchange}) | ||
th #{settings.locale.mkt_amount} (#{marketdata.coin}) | ||
th.hidden-xs #{settings.locale.mkt_total} (#{marketdata.exchange}) | ||
tbody | ||
each sell in marketdata.data.sells | ||
tr | ||
td | ||
=sell.price | ||
td | ||
=sell.amount | ||
td.hidden-xs | ||
=sell.total | ||
.row | ||
.col-md-12 | ||
.panel.panel-default | ||
.panel-heading | ||
h3.panel-title #{settings.locale.mkt_trade_history} | ||
table.table.table-hover.history-table.table-bordered(cellspacing="0") | ||
thead | ||
tr | ||
th.hidden-xs #{settings.locale.mkt_type} | ||
th #{settings.locale.mkt_amount} (#{marketdata.coin}) | ||
th #{settings.locale.mkt_price} (#{marketdata.exchange}) | ||
th #{settings.locale.mkt_total} (#{marketdata.exchange}) | ||
th.hidden-xs #{settings.locale.mkt_time_stamp} | ||
tbody | ||
each order in marketdata.data.history | ||
if order.side == 'buy' | ||
tr.success | ||
td.hidden-xs | ||
=order.side | ||
td | ||
=parseFloat(order.volume).toFixed(8) | ||
td | ||
=parseFloat(order.price).toFixed(8) | ||
td | ||
=parseFloat(order.funds).toFixed(8) | ||
td.hidden-xs | ||
=(new Date(order.timestamp * 1000).toUTCString()) | ||
else | ||
tr.danger | ||
td.hidden-xs | ||
=order.side | ||
td | ||
=parseFloat(order.volume).toFixed(8) | ||
td | ||
=parseFloat(order.price).toFixed(8) | ||
td | ||
=parseFloat(order.funds).toFixed(8) | ||
td.hidden-xs | ||
=(new Date(order.timestamp * 1000).toUTCString()) | ||
|
||
.footer-padding | ||
|