diff --git a/README.md b/README.md index 915dd44..99624f9 100644 --- a/README.md +++ b/README.md @@ -100,11 +100,11 @@ 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. Has the ability to integrate directly with exchange apis and/or the coingecko api from [https://www.coingecko.com/en/api](https://www.coingecko.com/en/api) to retrieve current market prices and convert to USD. The following 7 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. Has the ability to integrate directly with exchange apis and/or the coingecko api from [https://www.coingecko.com/en/api](https://www.coingecko.com/en/api) to retrieve current market prices and convert to USD. The following 8 cryptocurrency exchanges are supported: - [AltMarkets](https://altmarkets.io) - [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* - - [NonKyc](https://nonkyc.io) *\*no chart support due to a lack of OHLCV api data* + - [NonKyc](https://nonkyc.io) - [Poloniex](https://poloniex.com) - [SouthXchange](https://southxchange.com) - [Xeggex](https://xeggex.com) *\*no chart support due to a lack of OHLCV api data* diff --git a/lib/markets/nonkyc.js b/lib/markets/nonkyc.js index fe51a05..7735959 100644 --- a/lib/markets/nonkyc.js +++ b/lib/markets/nonkyc.js @@ -113,6 +113,43 @@ function get_orders(coin, exchange, api_error_msg, cb) { }); } +function get_chartdata(coin, exchange, api_error_msg, cb) { + const end = Date.now() / 1000; + const start = end - 86400; + const req_url = base_url + '/market/candles/?symbol=' + coin + '_' + exchange + '&from=' + parseInt(start).toString() + '&to=' + parseInt(end).toString() + '&resolution=15' ; + + // pause for 2 seconds before continuing + rateLimit.schedule(function() { + request({uri: req_url, json: true}, function (error, response, body) { + if (error) + return cb(error, null); + else if (body == null || body == '' || typeof body !== 'object' || typeof body == 'string' || body instanceof String) + return cb(api_error_msg, null); + else if (body.error != null) + return cb((body.error.message != null ? body.error.message : api_error_msg), null); + else { + try { + let chartdata = []; + + for (let c = 0; c < body.bars.length; c++) { + chartdata.push([ + parseInt(body.bars[c].time), + parseFloat(body.bars[c].open) || 0, + parseFloat(body.bars[c].high) || 0, + parseFloat(body.bars[c].low) || 0, + parseFloat(body.bars[c].close) || 0 + ]); + } + + return cb(null, chartdata); + } catch(err) { + return cb(api_error_msg, null); + } + } + }); + }); +} + module.exports = { market_name: 'Nonkyc', market_logo: 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAKrmlDQ1BJQ0MgUHJvZmlsZQAASImVlwdUE1kXgN/MpBdaQihSQm/SWwApIbTQpYONkAQIJcZAQLEjiyu4FlREUFF0VUTBtQBiRxTbotiwb5BFRFkXC6Ki8g9wCLv7n///z3/Peed+c+e+e+97M2/OHQCoKjyJJAtWASBbnCuNCvRlJiQmMfF9AAFaAABdQOTxcyTsyMhQ9ApM6r/Lx/sAGtN3rMdi/fv9/yqqAmEOHwAoEuUUQQ4/G+Xj6HjFl0hzAUB2oXaj/FzJGLehTJeiBaL8YIzTJnhgjFPGGQPGfWKiOCjTASBQeDxpGgAUJmpn5vHT0DgUH5TtxAKRGGUJyl7Z2fMFKB9B2Rz1QW2UsfislL/ESftbzBRFTB4vTcETaxkXgp8oR5LFW/R/bsf/luws2WQOU3RQ0qVBUWP50D17kDk/RMHilPCISRYJJmoa43RZUOwk83M4SZMs4PmFKOZmhYdOcqoogKuIk8uNmWRhjn/0JEvnRylypUo57EnmScfzklCWyzJjFfZ0IVcRvyA9Jn6S80Rx4ZOckxkdMuXDUdilsihF/UJxoO9U3gDF2rNz/rJeEVcxNzc9Jkixdt5U/UIxeypmToK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CTNbg7ZHgJaCtIghEJjaCxpdsb5ZrPtJkTwHXa+7/3a9968IWSCSEko1J5XuOF5xWngSAccFxYnwFI6rFSytV4IOU/p4GboYzPYxv3/yR3nwvm/AxG0s5O7Pinr1pZtTLLpksrlxxxBq8/bD7JWuuX7xfvgrvt21XXzT4EtK/Py9mKqVavlFsCREKfuq93OSBAzSfYOW7/fn572m+Cci29SChdYCFI5bHU/mObVn+C2jXlJPWxwUi47ugpNxrj6qxnpcUoZ/h2YVyqvbzHG6cqK06zX1+cSl8yPvT/i3dKS8933C5uU0mPL+rTZaBSXGZMbJycyR+nnX563fqffD444Y0bGNClKaQYBT6uAJ4yRFLIzxpaJFEfAag8yhsEeGUZwBVxZpxMJPgix+sbLOlcOwUivShcNUJtxx9E9o9dqtWCN9wzH7e3c5d3dfDYKxonEjFJHELKnpzk1ZdzLWik/CNhDBFWr+Vee9+YZ8MwMf7Ewn27Mzl6bA4eoduVw8iWVhJBej9d/7HfWpDRr4J2O+JJMDrTt7Gzw9WD/eK3b7R3AZtthDLCW8ccSn0kcD90v7n+oOE+CfYhmonq+q7ZxEcaw59FdgX5kedRlqo10BlEC9RoTqjK9pbZtSTWvAEFx+QtkiuwAOEtBDgAAAABJRU5ErkJggg==', @@ -124,9 +161,14 @@ module.exports = { get_trades(settings.coin, settings.exchange, settings.api_error_msg, function(trade_error, trades) { if (trade_error == null) { get_summary(settings.coin, settings.exchange, settings.api_error_msg, function(summary_error, stats) { - if (summary_error == null) - return cb(null, {buys: buys, sells: sells, trades: trades, stats: stats, chartdata: null}); - else + if (summary_error == null) { + get_chartdata(settings.coin, settings.exchange, settings.api_error_msg, function (chart_error, chartdata) { + if (chart_error == null) + return cb(null, {buys: buys, sells: sells, trades: trades, stats: stats, chartdata: chartdata}); + else + return cb(chart_error, null); + }); + } else return cb(summary_error, null); }); } else diff --git a/lib/settings.js b/lib/settings.js index eefb224..b47f416 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -834,7 +834,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, dex-trade, freiexchange/freixlite, poloniex, southxchange, xeggex, yobit + // Supported exchanges: altmarkets, dex-trade, freiexchange/freixlite, nonkyc, poloniex, southxchange, xeggex, yobit "exchanges": { // altmarkets: a collection of settings that pertain to the altmarkets exchange "altmarkets": { @@ -871,17 +871,16 @@ exports.markets_page = { "trading_pairs": [ "LTC/BTC" ] }, // nonkyc: a collection of settings that pertain to the nonkyc exchange - // NOTE: nonkyc does not display a 24-hour chart due to a lack of OHLCV api data - "nonkyc": { - // enabled: Enable/disable the nonkyc exchange (true/false) - // If set to false, the nonkyc 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/USDT" ] - }, + "nonkyc": { + // enabled: Enable/disable the nonkyc exchange (true/false) + // If set to false, the nonkyc 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/USDT" ] + }, // poloniex: a collection of settings that pertain to the poloniex exchange "poloniex": { // enabled: Enable/disable the poloniex exchange (true/false) diff --git a/settings.json.template b/settings.json.template index 79e2424..fd39886 100644 --- a/settings.json.template +++ b/settings.json.template @@ -955,17 +955,16 @@ "trading_pairs": [ "LTC/BTC" ] }, // nonkyc: a collection of settings that pertain to the nonkyc exchange - // NOTE: nonkyc does not display a 24-hour chart due to a lack of OHLCV api data - "nonkyc": { - // enabled: Enable/disable the nonkyc exchange (true/false) - // If set to false, the nonkyc 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/USDT" ] - }, + "nonkyc": { + // enabled: Enable/disable the nonkyc exchange (true/false) + // If set to false, the nonkyc 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/USDT" ] + }, // poloniex: a collection of settings that pertain to the poloniex exchange "poloniex": { // enabled: Enable/disable the poloniex exchange (true/false)