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 0aa95ac
Showing
6 changed files
with
231 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,110 @@ | ||
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 + exchange; | ||
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 + 'k?market=' + coin + exchange + '&limit=100'; | ||
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 { | ||
var tTrades = body; | ||
var trades = []; | ||
// for (var i = 0; i < tTrades.length; i++) { | ||
// var Trade = { | ||
// orderpair: tTrades[i].Label, | ||
// ordertype: tTrades[i].Type, | ||
// amount: parseFloat(tTrades[i].Amount).toFixed(8), | ||
// price: parseFloat(tTrades[i].Price).toFixed(8), | ||
// // total: parseFloat(tTrades[i].Total).toFixed(8) | ||
// // Necessary because API will return 0.00 for small volume transactions | ||
// total: (parseFloat(tTrades[i].Amount).toFixed(8) * parseFloat(tTrades[i].Price)).toFixed(8), | ||
// timestamp: tTrades[i].Timestamp | ||
// } | ||
// trades.push(Trade); | ||
// } | ||
return cb(null, trades); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
function get_orders(coin, exchange, cb) { | ||
var req_url = base_url + 'depth?market=' + coin + exchange; | ||
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,110 @@ | ||
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} | ||
th #{settings.locale.mkt_change} | ||
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.ordertype == 'Buy' | ||
tr.success | ||
td.hidden-xs | ||
=order.ordertype | ||
td | ||
=order.amount | ||
td | ||
=order.price | ||
td | ||
=order.total | ||
td.hidden-xs | ||
=(new Date(order.timestamp * 1000).toUTCString()) | ||
else | ||
tr.danger | ||
td.hidden-xs | ||
=order.ordertype | ||
td | ||
=order.amount | ||
td | ||
=order.price | ||
td | ||
=order.total | ||
td.hidden-xs | ||
=(new Date(order.timestamp * 1000).toUTCString()) | ||
|
||
.footer-padding | ||
|
0aa95ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamjustarandomguy @cryptozeny their API doesn't include trades yet so I was waiting to do a PR until then
0aa95ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamjustarandomguy this is now fixed and fully working:
cf0ad6d
https://explorer.theholyroger.com/markets/altmarkets
0aa95ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iquidus#307
0aa95ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @iamjustarandomguy index for which collection/fields?