Stex market fixes

This commit is contained in:
joeuhren
2020-11-23 17:20:30 -07:00
parent d175db4dae
commit 594566c606
3 changed files with 35 additions and 12 deletions
+35 -10
View File
@@ -120,21 +120,46 @@ function get_chartdata(coin, exchange, stex_id, cb) {
*/
}
function get_pair_id(coin, exchange, cb) {
// Lookup the currency pair id needed to use the stex api
request({ uri: base_url + '/currency_pairs/list/' + exchange, json: true, headers: {'User-Agent': 'eiquidus'} }, function (error, response, body) {
if (error)
return cb(error, null);
else if (body.success === true) {
var stex_id = 0;
// Find the currency pair
for (i = 0; i < body.data.length; i++) {
if (body.data[i].currency_code.toUpperCase() == coin.toUpperCase()) {
stex_id = body.data[i].id;
break;
}
}
return cb(null, stex_id);
} else
return cb(error, null);
}).on('error', function(err) {
return cb(error, null);
});
}
module.exports = {
get_data: function (coin, exchange, stex_id, cb) {
get_data: function (settings, cb) {
var error = null;
get_chartdata(coin, exchange, stex_id, function (err, chartdata) {
if (err) { chartdata = []; error = err; }
get_orders(coin, exchange, stex_id, function (err, buys, sells) {
get_pair_id(settings.coin, settings.exchange, function (err, stex_id) {
get_chartdata(settings.coin, settings.exchange, stex_id, function (err, chartdata) {
if (err) { chartdata = []; error = err; }
get_orders(settings.coin, settings.exchange, stex_id, function (err, buys, sells) {
if (err) { error = err; }
get_trades(coin, exchange, stex_id, function (err, trades) {
get_trades(settings.coin, settings.exchange, stex_id, function (err, trades) {
if (err) { error = err; }
get_summary(coin, exchange, stex_id, function (err, stats) {
if (err) { error = err; }
return cb(error, { buys: buys, sells: sells, chartdata: chartdata, trades: trades, stats: stats });
get_summary(settings.coin, settings.exchange, stex_id, function (err, stats) {
if (err) { error = err; }
return cb(error, { buys: buys, sells: sells, chartdata: chartdata, trades: trades, stats: stats });
});
});
});
});
});
});
});
}
};
-1
View File
@@ -95,7 +95,6 @@ exports.markets = {
"coin": "EXOR",
"exchange": "BTC",
"enabled": [],
"stex_id": "",
"default": ""
};
-1
View File
@@ -122,7 +122,6 @@
"coin": "EXOR",
"exchange": "BTC",
"enabled": [],
"stex_id": "",
"default": ""
},