Add TradeSatoshi Support
This commit is contained in:
+7
-1
@@ -16,7 +16,8 @@ var mongoose = require('mongoose')
|
||||
, stex = require('./markets/stex')
|
||||
, crex = require('./markets/crex')
|
||||
, coindesk = require('./apis/coindesk')
|
||||
, altmarkets = require('./markets/altmarkets');
|
||||
, altmarkets = require('./markets/altmarkets')
|
||||
, tradesatoshi = require('./markets/tradesatoshi');
|
||||
|
||||
function find_address(hash, caseSensitive, cb) {
|
||||
if (caseSensitive) {
|
||||
@@ -244,6 +245,11 @@ function get_market_data(market, cb) {
|
||||
return cb(err, obj);
|
||||
});
|
||||
break;
|
||||
case 'tradesatoshi':
|
||||
tradesatoshi.get_data(settings.markets.coin, settings.markets.exchange, function (err, obj){
|
||||
return cb(err, obj);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
return cb(null);
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ exports.bleutrade = "Bleutrade",
|
||||
exports.yobit = "Yobit",
|
||||
exports.stex = "Stex",
|
||||
exports.crex = "Crex24",
|
||||
exports.tradesatoshi = "TradeSatoshi",
|
||||
|
||||
exports.reloadLocale = function reloadLocale(locale) {
|
||||
// Discover where the locale file lives
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
var request = require('request');
|
||||
|
||||
var base_url = 'https://tradesatoshi.com/api/public/';
|
||||
function get_summary(coin, exchange, cb) {
|
||||
var summary = {};
|
||||
request({ uri: base_url + 'getmarketsummary?market=' + coin + '_' + exchange, json: true }, function (error, response, body) {
|
||||
if (error) {
|
||||
return cb(error, null);
|
||||
} else {
|
||||
summary['bid'] = body.result['bid'];
|
||||
summary['ask'] = body.result['ask'];
|
||||
summary['volume'] = body.result['volume'];
|
||||
summary['high'] = body.result['high'];
|
||||
summary['low'] = body.result['low'];
|
||||
summary['last'] = body.result['last'];
|
||||
summary['change'] = body.result['change'];
|
||||
return cb(null, summary);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function get_trades(coin, exchange, cb) {
|
||||
var req_url = base_url + 'getmarkethistory?market=' + coin + '_' + exchange + '&count=1000';
|
||||
request({uri: req_url, json: true}, function (error, response, body) {
|
||||
if (body.success == true) {
|
||||
return cb (null, body['result']);
|
||||
} else {
|
||||
return cb(body.message, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function get_orders(coin, exchange, cb) {
|
||||
var req_url = base_url + 'getorderbook?market=' + coin + '_' + exchange + '&type=both&depth=1000';
|
||||
request({ uri: req_url, json: true }, function (error, response, body) {
|
||||
if (body.success) {
|
||||
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].quantity).toFixed(8) * parseFloat(orders.buy[i].rate)).toFixed(8)
|
||||
}
|
||||
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].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 = {
|
||||
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});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -138,6 +138,7 @@
|
||||
"yobit": "Yobit",
|
||||
"stex": "Stex",
|
||||
"crex": "Crex24",
|
||||
"tradesatoshi": "TradeSatoshi",
|
||||
|
||||
// Heavy rewards view
|
||||
"heavy_title": "Reward/voting information",
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
extends menu
|
||||
|
||||
block market_view
|
||||
.row
|
||||
.col-md-12
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
strong #{settings.locale.tradesatoshi} - #{marketdata.coin}/#{marketdata.exchange} - #{settings.locale.mkt_hours}
|
||||
a(href='https://coinmarketcap.com/currencies/#{settings.coin}/#charts')
|
||||
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.toFixed(8)}
|
||||
td #{marketdata.data.summary.low.toFixed(8)}
|
||||
td #{marketdata.data.summary.volume.toFixed(2).replace(/(?:\.0+|(\.\d+?)0+)$/, "$1")}
|
||||
td.hidden-xs #{marketdata.data.summary.bid.toFixed(8)}
|
||||
td.hidden-xs #{marketdata.data.summary.ask.toFixed(8)}
|
||||
td.hidden-xs #{marketdata.data.summary.last.toFixed(8)}
|
||||
- var tradesatoshi_change = parseFloat(marketdata.data.summary.change).toFixed(4).replace(/(?:\.0+|(\.\d+?)0+)$/, "$1");
|
||||
if tradesatoshi_change >= 0
|
||||
td.success +#{tradesatoshi_change} %
|
||||
else
|
||||
td.danger #{tradesatoshi_change} %
|
||||
.row
|
||||
.col-md-6.col-xs-12
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
h3.panel-title #{settings.locale.mkt_buy_orders}
|
||||
table.table.table-hover.history-table.table-bordered(cellspacing="0")
|
||||
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-hover.history-table.table-bordered(cellspacing="0")
|
||||
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 result in marketdata.data.history
|
||||
if result.orderType == 'Sell'
|
||||
tr.danger
|
||||
td.hidden-xs
|
||||
=result.orderType
|
||||
td
|
||||
=result.quantity.toFixed(8).replace(/(?:\.0+|(\.\d+?)0+)$/, "$1")
|
||||
td
|
||||
=result.price.toFixed(8)
|
||||
td
|
||||
=result.total.toFixed(8).replace(/(?:\.0+|(\.\d+?)0+)$/, "$1")
|
||||
td.hidden-xs
|
||||
=result.timeStamp.substr(0, 19).replace("T", " ")
|
||||
else
|
||||
tr.success
|
||||
td.hidden-xs
|
||||
=result.orderType
|
||||
td
|
||||
=result.quantity.toFixed(8).replace(/(?:\.0+|(\.\d+?)0+)$/, "$1")
|
||||
td
|
||||
=result.price.toFixed(8)
|
||||
td
|
||||
=result.total.toFixed(8).replace(/(?:\.0+|(\.\d+?)0+)$/, "$1")
|
||||
td.hidden-xs
|
||||
=result.timeStamp.substr(0, 19).replace("T", " ")
|
||||
.footer-padding
|
||||
Reference in New Issue
Block a user