Add Dex-Trade exchange to markets

This commit is contained in:
Joe Uhren
2022-06-27 18:55:12 -06:00
parent 2584fbda2a
commit fb5ce795fa
4 changed files with 166 additions and 3 deletions
+2 -1
View File
@@ -87,11 +87,12 @@ Table of Contents
- **Movement:** Displays latest blockchain transactions that are greater than a certain configurable amount
- **Network:** Displays a list of peers that have connected to the coind wallet in the past 24 hours, along with useful addnode data that can be used to connect your own wallets to the network easier
- **Top 100:** Displays the top 100 richest wallet addresses, the top 100 wallet addresses that have the highest total number of coins received based on adding up all received transactions, as well as a table and pie chart breakdown of wealth distribution. Additional support for omitting burned coins from top 100 lists
- **Markets:** Displays a number of exchange-related metrics including market summary, 24 hour chart, most recent buy/sell orders and latest trade history. The last known default exchange price is automatically converted to USD using the coingecko api from [https://www.coingecko.com/en/api](https://www.coingecko.com/en/api). The following 9 cryptocurrency exchanges are supported:
- **Markets:** Displays a number of exchange-related metrics including market summary, 24 hour chart, most recent buy/sell orders and latest trade history. The last known default exchange price is automatically converted to USD using the coingecko api from [https://www.coingecko.com/en/api](https://www.coingecko.com/en/api). The following 10 cryptocurrency exchanges are supported:
- [AltMarkets](https://altmarkets.io)
- [Bittrex](https://bittrex.com)
- [Bleutrade](https://bleutrade.com)
- [Crex24](https://crex24.com)
- [Dex-Trade](https://dex-trade.com)
- [FreiExchange](https://freiexchange.com)/[FreiXLite](https://freixlite.com) *\*no chart support due to a lack of OHLCV api data*
- [Poloniex](https://poloniex.com)
- [SouthXchange](https://southxchange.com)
+141
View File
@@ -0,0 +1,141 @@
const request = require('postman-request');
const base_url = 'https://api.dex-trade.com/v1/public/';
const base_chart_url = 'https://socket.dex-trade.com/graph/';
const api_error_msg = 'api did not return any data';
const market_url_template = 'https://dex-trade.com/spot/trading/{coin}{base}';
function get_summary(coin, exchange, bid, ask, cb) {
var summary = {};
request({ uri: base_url + 'ticker?pair=' + coin + exchange, json: true}, function (error, response, body) {
if (error)
return cb(error, null);
else if (body.status == null || body.status == false)
return cb(body.error, null);
else {
summary['bid'] = bid;
summary['ask'] = ask;
summary['high'] = body.data['high'];
summary['low'] = body.data['low'];
summary['volume'] = body.data['volume_24H'];
summary['last'] = body.data['last'];
return cb(null, summary);
}
}).on('error', function(err) {
return cb(error, null);
});
}
function get_trades(coin, exchange, cb) {
var req_url = base_url + 'trades?pair=' + coin + exchange;
request({ uri: req_url, json: true}, function (error, response, body) {
if (error)
return cb(error, null);
else if (body.status == null || body.status == false)
return cb(body.error, null);
else {
var trade_body = body.data;
var trades = [];
for (var i = 0; i < trade_body.length; i++) {
trades.push({
ordertype: trade_body[i].type,
price: trade_body[i].rate,
quantity: trade_body[i].volume,
timestamp: trade_body[i].timestamp
});
}
return cb(null, trades);
}
}).on('error', function(err) {
return cb(error, null);
});
}
function get_orders(coin, exchange, cb) {
var req_url = base_url + 'book?pair=' + coin + exchange;
request({ uri: req_url, json: true}, function (error, response, body) {
if (error)
return cb(error, [], []);
else if (body.status == null || body.status == false)
return cb(body.error, null);
else {
var orders = body.data;
var buys = [];
var sells = [];
if (orders['buy'].length > 0){
for (var i = 0; i < orders['buy'].length; i++) {
buys.push({
price: orders['buy'][i].rate,
quantity: orders['buy'][i].volume
});
}
}
if (orders['sell'].length > 0) {
for (var i = 0; i < orders['sell'].length; i++) {
sells.push({
price: orders['sell'][i].rate,
quantity: orders['sell'][i].volume
});
}
}
return cb(null, buys, sells);
}
}).on('error', function(err) {
return cb(error, null, null);
});
}
function get_chartdata(coin, exchange, cb) {
var end = Date.now();
var start = end - 86400000;
var req_url = base_chart_url + 'hist?t=' + coin + exchange + '&r=15&limit=100';
request({ uri: req_url, json: true}, function (error, response, chartdata) {
if (error)
return cb(error, []);
else if (chartdata == null)
return cb(api_error_msg, null);
else {
var processed = [];
for (var i = 0; i < chartdata.length; i++) {
// only take values more recent than the last 24 hours
if (chartdata[i].time * 1000 > start)
processed.push([chartdata[i].time * 1000, chartdata[i].open, chartdata[i].high, chartdata[i].low, chartdata[i].close]);
}
return cb(null, processed);
}
});
}
module.exports = {
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hdI3B4/PC6/Xh1q3bKC2rxPETp7fR0vIyvfn2+x/LMnOhe1GPg4ePwniyHq2t7VxkaelPhhACU/+MUCiS8vJfNbxuWlldZavsnyLvZICU6qLecCAiJhmFRdv5Kh87ZkRbeweustK9vrtsmQY4OTunwOp2eykwPUvUZxmhwMw8ucYnqLTM8EnsGjFfKqK4fz+VgCGGE6MFKXhZv69jcMgWOb8QIuuwk2jI5iSbY4wGbaP0a6+Z6usbnynWlXzBlmRMqlAHMxS5wY25GvfTz+00nTB+tKPHfIP6+gfJ5ZogO+P9DaehK5oI+uoTAAAAAElFTkSuQmCC',
market_url_template: market_url_template,
market_url_case: 'u',
get_data: function(settings, cb) {
var error = null;
get_chartdata(settings.coin.toUpperCase(), settings.exchange.toUpperCase(), function (err, chartdata) {
if (err) { chartdata = []; error = err; }
get_orders(settings.coin.toUpperCase(), settings.exchange.toUpperCase(), function(err, buys, sells) {
if (err) { error = err; }
get_trades(settings.coin.toUpperCase(), settings.exchange.toUpperCase(), function(err, trades) {
if (err) { error = err; }
get_summary(settings.coin.toUpperCase(), settings.exchange.toUpperCase(), (buys == null || buys.length == 0 ? null : buys[0].price), (sells == null || sells.length == 0 ? null : sells[0].price), function(err, stats) {
if (err) { error = err; }
return cb(error, {buys: buys, sells: sells, chartdata: chartdata, trades: trades, stats: stats});
});
});
});
});
}
};
+11 -1
View File
@@ -729,7 +729,7 @@ exports.markets_page = {
"show_market_select": true,
// exchanges: Enable/disable api integration with any of the available built-in exchanges
// Enabled exchanges display a number of exchange-related metrics including market summary, 24 hour chart, most recent buy/sell orders and latest trade history
// Supported exchanges: altmarkets, bittrex, bleutrade, crex, freiexchange/freixlite, poloniex, southxchange, stex, yobit
// Supported exchanges: altmarkets, bittrex, bleutrade, crex, dex-trade, freiexchange/freixlite, poloniex, southxchange, stex, yobit
"exchanges": {
// altmarkets: a collection of settings that pertain to the altmarkets exchange
"altmarkets": {
@@ -775,6 +775,16 @@ exports.markets_page = {
// Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH"
"trading_pairs": [ "LTC/BTC" ]
},
"dextrade": {
// enabled: Enable/disable the dex-trade exchange (true/false)
// If set to false, the dex-trade page will be completely inaccessible and no market data will be downloaded for this exchange
"enabled": false,
// trading_pairs: An array of market trading pair symbols
// You can add as many trading pairs as necessary
// All entries must specify your coins symbol as it is displayed on the exchange, followed by a slash (/) and ending with the symbol of the market or asset that is being traded against
// Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH"
"trading_pairs": [ "LTC/BTC" ]
},
"freiexchange": {
// enabled: Enable/disable the freiexchange/freixlite exchange (true/false)
// If set to false, the freiexchange/freixlite page will be completely inaccessible and no market data will be downloaded for this exchange
+12 -1
View File
@@ -813,7 +813,7 @@
"show_market_select": true,
// exchanges: Enable/disable api integration with any of the available built-in exchanges
// Enabled exchanges display a number of exchange-related metrics including market summary, 24 hour chart, most recent buy/sell orders and latest trade history
// Supported exchanges: altmarkets, bittrex, bleutrade, crex, freiexchange/freixlite, poloniex, southxchange, stex, yobit
// Supported exchanges: altmarkets, bittrex, bleutrade, crex, dex-trade, freiexchange/freixlite, poloniex, southxchange, stex, yobit
"exchanges": {
// altmarkets: a collection of settings that pertain to the altmarkets exchange
"altmarkets": {
@@ -859,6 +859,17 @@
// Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH"
"trading_pairs": [ "LTC/BTC" ]
},
// dextrade: a collection of settings that pertain to the dex-trade exchange
"dextrade": {
// enabled: Enable/disable the dex-trade exchange (true/false)
// If set to false, the dex-trade page will be completely inaccessible and no market data will be downloaded for this exchange
"enabled": false,
// trading_pairs: An array of market trading pair symbols
// You can add as many trading pairs as necessary
// All entries must specify your coins symbol as it is displayed on the exchange, followed by a slash (/) and ending with the symbol of the market or asset that is being traded against
// Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH"
"trading_pairs": [ "LTC/BTC" ]
},
// freiexchange: a collection of settings that pertain to the freiexchange/freixlite exchange
"freiexchange": {
// enabled: Enable/disable the freiexchange/freixlite exchange (true/false)