From 1c1fde39d9d8933e8ec56aa58be2a54b5792866f Mon Sep 17 00:00:00 2001 From: sudormdir Date: Tue, 19 Sep 2023 02:11:12 -0500 Subject: [PATCH 1/4] Add Xeggex support --- README.md | 3 +- lib/markets/xeggex.js | 125 +++++++++++++++++++++++++++++++++++++++++ lib/settings.js | 17 +++++- settings.json.template | 15 ++++- 4 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 lib/markets/xeggex.js diff --git a/README.md b/README.md index a35221e..3f3a5f1 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Table of Contents - [SouthXchange](https://southxchange.com) - [Txbit](https://txbit.io) *\*no chart support due to a lack of OHLCV api data* - [Unnamed](https://unnamed.exchange) + - [Xeggex](https://xeggex.com) *\*no chart support due to a lack of OHLCV api data* - [Yobit](https://yobit.io) *\*no chart support due to a lack of OHLCV api data* - **API:** A listing of available public API's that can be used to retrieve information from the network without the need for a local wallet. The following public API's are supported: - **RPC API calls** (Return data from coind) @@ -985,4 +986,4 @@ Redistribution and use in source and binary forms, with or without modification, * Neither the name of Iquidus Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/markets/xeggex.js b/lib/markets/xeggex.js new file mode 100644 index 0000000..7f637ab --- /dev/null +++ b/lib/markets/xeggex.js @@ -0,0 +1,125 @@ +var request = require('postman-request'); +var base_url = 'https://api.xeggex.com/api/v2'; +const market_url_template = 'https://xeggex.com/market/{coin}_{base}'; + +function get_summary(coin, exchange, cb) { + var req_url = base_url + '/market/getbysymbol/' + coin + '_' + exchange; + + request({uri: req_url, json: true}, function (error, response, body) { + if (error) + return cb(error, null); + else { + if (body.message) + return cb(body.message, null); + else { + var retVal = { + 'high': body.highPriceNumber, + 'low': body.lowPriceNumber, + 'volume': body.volumeUsdNumber, + 'bid': body.bestBidNumber, + 'ask': body.bestAskNumber, + 'last': body.lastPriceNumber, + 'prev': body.yesterdayPriceNumber + }; + + return cb (null, retVal); + } + } + }); +} + +function formatTimestamp(unixTimestamp) { + const date = new Date(unixTimestamp * 1000); // Convert to milliseconds + const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + + const day = date.getUTCDate(); + const month = months[date.getUTCMonth()]; + const year = date.getUTCFullYear(); + + const hours = String(date.getUTCHours()).padStart(2, '0'); + const minutes = String(date.getUTCMinutes()).padStart(2, '0'); + const seconds = String(date.getUTCSeconds()).padStart(2, '0'); + + return `${month} ${day}, ${year} ${hours}:${minutes}:${seconds} UTC`; +} +function get_trades(coin, exchange, cb) { + + // Now proceed to the second API request + var req_url = base_url + '/historical_trades?ticker_id=' + coin + '_' + exchange + '&limit=300' ; + + request({uri: req_url, json: true}, function (error, response, body) { + if (error) return cb(error, null); + + var trades = []; + + if (body.length > 0) { + for (var i = 0; i < body.length; i++) { + var trade = { + ordertype: body[i]['type'], + price: body[i]['price'], + quantity: body[i]['base_volume'], + timestamp: formatTimestamp(parseInt(new Date(body[i]['trade_timestamp']).getTime()/1000)) + }; + trades.push(trade); + } + } + return cb(null, trades); + }); +} + +function get_orders(coin, exchange, cb) { + var req_url = base_url + '/market/getorderbookbysymbol/' + coin + '_' + exchange + + request({uri: req_url, json: true}, function (error, response, body) { + if (body) { + var orders = body; + var buys = []; + var sells = []; + + if (orders['bids'].length > 0) { + for (var i = 0; i < orders['bids'].length; i++) { + var order = { + price: orders.bids[i].numberprice, + quantity: orders.bids[i].quantity + }; + + buys.push(order); + } + } + + if (orders['asks'].length > 0) { + for (var i = 0; i < orders['asks'].length; i++) { + var order = { + price: orders.asks[i].numberprice, + quantity: orders.asks[i].quantity + }; + + sells.push(order); + } + } + + return cb(null, buys, sells); + } else + return cb(body, [], []); + }); +} + +module.exports = { + market_name: 'Xeggex', + market_logo: 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF8WlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDIgNzkuMTY0NDYwLCAyMDIwLzA1LzEyLTE2OjA0OjE3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bW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xPW5WtL4JgVQQLBZ96bNp77A29vlKvtjUu1Tu/CYLQZkq0eynYNT0ZKTlJvS5WS7EduaL7e8cntDfb3n9x3nAfxAjeOfQqDGJVO/xwnOsK1OVlb7s44f934HJzD7B1FKUrmvEE0w/LiZFT3jtgrvXO83YXe2TzNcPY6gXOMXFraYfXD1aRVBUoW0sI0AtfpmUfGaeynxZrV6YfR9gaYNjC5Gdt4/rG2ntiWS2hTgDO5fnCPNBUXUBxj3/0OJ8l5US+DxQlYmtlpqxp2XjoEZBosSjkNVYA4I85BCxAcplk6jaYHlBxkyoI3iM54hWZWN+DBA40zK0cPghMAR4Iq9il4Ckj1b5LFyUdipf8Cba+9zaJkr9qMf7GT9HC1HxwVxuD2+DbwIHqX4uxBqpcug/SzEOxpFAbcDz9k1id/At3gdXn7zpxjdKXaHcDNC4hCR4aL83HZAbSeLSzL7R2aQLxrGFR1A9Hx35frm18y69NFYCuBc62z09Zmthwmw1aU9Aslzxspbqq0QFKydttR+qoYxI21J/at+dOPXpA31pZFEONfwAie3PFmXOIAAAAASUVORK5CYII=', + market_url_template: market_url_template, + market_url_case: 'u', + get_data: function(settings, cb) { + var error = null; + get_orders(settings.coin, settings.exchange, function(err, buys, sells) { + if (err) { error = err; } + get_trades(settings.coin, settings.exchange, function(err, trades) { + if (err) { error = err; } + get_summary(settings.coin, settings.exchange, function(err, stats) { + if (err) { error = err; } + return cb(error, {buys: buys, sells: sells, trades: trades, stats: stats}); + }); + }); + }); + } +}; diff --git a/lib/settings.js b/lib/settings.js index 1293979..402b72d 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -803,7 +803,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, dex-trade, freiexchange/freixlite, poloniex, southxchange, txbit, unnamed, yobit + // Supported exchanges: altmarkets, bittrex, bleutrade, crex, dex-trade, freiexchange/freixlite, poloniex, southxchange, txbit, unnamed, xeggex, yobit "exchanges": { // altmarkets: a collection of settings that pertain to the altmarkets exchange "altmarkets": { @@ -929,6 +929,19 @@ exports.markets_page = { // Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH" "trading_pairs": [ "LTC/BTC" ] } + }, + // xeggex: a collection of settings that pertain to the xeggex exchange + // NOTE: xeggex does not display a 24-hour chart due to a lack of OHLCV api data + "xeggex": { + // enabled: Enable/disable the xeggex exchange (true/false) + // If set to false, the xeggex page will be completely inaccessible and no market data will be downloaded for this exchange + "enabled": true, + // 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" + } }, // default_exchange: a collection of settings that pertain to the default exchange // When the "show_market_dropdown_menu" setting is disabled, the market header menu will navigate directly to the default exchange page @@ -2049,4 +2062,4 @@ Object.byString = function(o, s) { } // populate settings -exports.loadSettings(); \ No newline at end of file +exports.loadSettings(); diff --git a/settings.json.template b/settings.json.template index eb3576b..bd0f9b1 100644 --- a/settings.json.template +++ b/settings.json.template @@ -887,7 +887,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, dex-trade, freiexchange/freixlite, poloniex, southxchange, txbit, unnamed, yobit + // Supported exchanges: altmarkets, bittrex, bleutrade, crex, dex-trade, freiexchange/freixlite, poloniex, southxchange, txbit, unnamed, xeggex, yobit "exchanges": { // altmarkets: a collection of settings that pertain to the altmarkets exchange "altmarkets": { @@ -1001,6 +1001,19 @@ // Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH" "trading_pairs": [ "LTC/BTC" ] }, + // xeggex: a collection of settings that pertain to the xeggex exchange + // NOTE: xeggex does not display a 24-hour chart due to a lack of OHLCV api data + "xeggex": { + // enabled: Enable/disable the xeggex exchange (true/false) + // If set to false, the xeggex page will be completely inaccessible and no market data will be downloaded for this exchange + "enabled": true, + // 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" + } + }, // yobit: a collection of settings that pertain to the yobit exchange // NOTE: yobit does not display a 24-hour chart due to a lack of OHLCV api data "yobit": { From 6554e7dddac22f3d5ecb48dbef50da066a1723c1 Mon Sep 17 00:00:00 2001 From: sudormdir <124973031+sudormdir@users.noreply.github.com> Date: Tue, 19 Sep 2023 02:16:43 -0500 Subject: [PATCH 2/4] Update settings.json.template --- settings.json.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.json.template b/settings.json.template index bd0f9b1..7109de9 100644 --- a/settings.json.template +++ b/settings.json.template @@ -1006,7 +1006,7 @@ "xeggex": { // enabled: Enable/disable the xeggex exchange (true/false) // If set to false, the xeggex page will be completely inaccessible and no market data will be downloaded for this exchange - "enabled": true, + "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 @@ -1599,4 +1599,4 @@ "enabled": false } } -} \ No newline at end of file +} From 46e590d845fd0252bd4fe4ea7ab779e04776b0c2 Mon Sep 17 00:00:00 2001 From: sudormdir <124973031+sudormdir@users.noreply.github.com> Date: Tue, 19 Sep 2023 02:18:11 -0500 Subject: [PATCH 3/4] Update settings.js --- lib/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/settings.js b/lib/settings.js index 402b72d..8bc1db2 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -935,7 +935,7 @@ exports.markets_page = { "xeggex": { // enabled: Enable/disable the xeggex exchange (true/false) // If set to false, the xeggex page will be completely inaccessible and no market data will be downloaded for this exchange - "enabled": true, + "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 From 69046e42615e4e0174073992d1ee8b9545b3039d Mon Sep 17 00:00:00 2001 From: Joe Uhren Date: Tue, 19 Sep 2023 20:53:30 -0600 Subject: [PATCH 4/4] Xeggex market improvements --- README.md | 4 +- lib/markets/xeggex.js | 109 ++++++++++++++++++++--------------------- lib/settings.js | 27 +++++----- settings.json.template | 7 ++- 4 files changed, 71 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 3f3a5f1..07570f0 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ 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 11 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 12 cryptocurrency exchanges are supported: - [AltMarkets](https://altmarkets.io) - [Bittrex](https://bittrex.com) - [Bleutrade](https://bleutrade.com) @@ -986,4 +986,4 @@ Redistribution and use in source and binary forms, with or without modification, * Neither the name of Iquidus Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/lib/markets/xeggex.js b/lib/markets/xeggex.js index 7f637ab..ef6bb7e 100644 --- a/lib/markets/xeggex.js +++ b/lib/markets/xeggex.js @@ -1,77 +1,73 @@ -var request = require('postman-request'); -var base_url = 'https://api.xeggex.com/api/v2'; +const request = require('postman-request'); +const base_url = 'https://api.xeggex.com/api/v2'; const market_url_template = 'https://xeggex.com/market/{coin}_{base}'; function get_summary(coin, exchange, cb) { - var req_url = base_url + '/market/getbysymbol/' + coin + '_' + exchange; + const req_url = base_url + '/market/getbysymbol/' + coin + '_' + exchange; request({uri: req_url, json: true}, function (error, response, body) { if (error) return cb(error, null); + else if (body.error != null) + return cb(body.error.message, null); else { - if (body.message) - return cb(body.message, null); - else { - var retVal = { - 'high': body.highPriceNumber, - 'low': body.lowPriceNumber, - 'volume': body.volumeUsdNumber, - 'bid': body.bestBidNumber, - 'ask': body.bestAskNumber, - 'last': body.lastPriceNumber, - 'prev': body.yesterdayPriceNumber - }; + var retVal = { + 'high': body.highPriceNumber, + 'low': body.lowPriceNumber, + 'volume': body.volumeNumber, + 'volume_btc': body.volumeUsdNumber, + 'bid': body.bestBidNumber, + 'ask': body.bestAskNumber, + 'last': body.lastPriceNumber, + 'prev': body.yesterdayPriceNumber, + 'change': body.changePercentNumber + }; - return cb (null, retVal); - } + return cb(null, retVal); } + }).on('error', function(err) { + return cb(err, null); }); } -function formatTimestamp(unixTimestamp) { - const date = new Date(unixTimestamp * 1000); // Convert to milliseconds - const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - - const day = date.getUTCDate(); - const month = months[date.getUTCMonth()]; - const year = date.getUTCFullYear(); - - const hours = String(date.getUTCHours()).padStart(2, '0'); - const minutes = String(date.getUTCMinutes()).padStart(2, '0'); - const seconds = String(date.getUTCSeconds()).padStart(2, '0'); - - return `${month} ${day}, ${year} ${hours}:${minutes}:${seconds} UTC`; -} function get_trades(coin, exchange, cb) { + const req_url = base_url + '/historical_trades?ticker_id=' + coin + '_' + exchange + '&limit=300' ; - // Now proceed to the second API request - var req_url = base_url + '/historical_trades?ticker_id=' + coin + '_' + exchange + '&limit=300' ; - - request({uri: req_url, json: true}, function (error, response, body) { - if (error) return cb(error, null); - + request({uri: req_url, json: true}, function (error, response, body) { + if (error) + return cb(error, null); + else if (body.error != null) + return cb(body.error.message, null); + else { var trades = []; - if (body.length > 0) { - for (var i = 0; i < body.length; i++) { - var trade = { - ordertype: body[i]['type'], - price: body[i]['price'], - quantity: body[i]['base_volume'], - timestamp: formatTimestamp(parseInt(new Date(body[i]['trade_timestamp']).getTime()/1000)) - }; - trades.push(trade); - } + for (var i = 0; i < body.length; i++) { + var trade = { + ordertype: body[i]['type'], + price: parseFloat(body[i]['price']), + quantity: parseFloat(body[i]['base_volume']), + timestamp: parseInt(new Date(body[i]['trade_timestamp']).getTime()/1000) + }; + + trades.push(trade); } + return cb(null, trades); - }); + } + }).on('error', function(err) { + return cb(err, null); + }); } function get_orders(coin, exchange, cb) { - var req_url = base_url + '/market/getorderbookbysymbol/' + coin + '_' + exchange + const req_url = base_url + '/market/getorderbookbysymbol/' + coin + '_' + exchange request({uri: req_url, json: true}, function (error, response, body) { - if (body) { + if (error) + return cb(error, [], []); + else if (body.error != null) + return cb(body.error.message, [], []); + else { var orders = body; var buys = []; var sells = []; @@ -80,7 +76,7 @@ function get_orders(coin, exchange, cb) { for (var i = 0; i < orders['bids'].length; i++) { var order = { price: orders.bids[i].numberprice, - quantity: orders.bids[i].quantity + quantity: parseFloat(orders.bids[i].quantity) }; buys.push(order); @@ -91,7 +87,7 @@ function get_orders(coin, exchange, cb) { for (var i = 0; i < orders['asks'].length; i++) { var order = { price: orders.asks[i].numberprice, - quantity: orders.asks[i].quantity + quantity: parseFloat(orders.asks[i].quantity) }; sells.push(order); @@ -99,14 +95,15 @@ function get_orders(coin, exchange, cb) { } return cb(null, buys, sells); - } else - return cb(body, [], []); + } + }).on('error', function(err) { + return cb(err, null, null); }); } module.exports = { market_name: 'Xeggex', - market_logo: 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF8WlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDIgNzkuMTY0NDYwLCAyMDIwLzA1LzEyLTE2OjA0OjE3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cm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POxbWso52OaBX69+7kysjIw7+8u66soJ6Ig3kjHAzaxeEAAACkSURBVBjThc03gsIwFADRkRyxyRl2yTl+SbZJ9z8YhQsKCl431fBlaBoPMTHEIs+GiQiahdevOh3m1b7nJgH4poPvWrp3YSlXgIrtou4ebG0FAA4Wle8Y3SJKYaLyNiprf1Y1E/Inn17ZlHWWpiGl0+1MlCfc92Un2QbmVtEtL2OZ4feClozpGB/0tPAG/5nWrjZYFM2Ao6u/xIwgNvKouyE/vQGJsQ9k11uR2AAAAABJRU5ErkJggg==', market_url_template: market_url_template, market_url_case: 'u', get_data: function(settings, cb) { @@ -122,4 +119,4 @@ module.exports = { }); }); } -}; +}; \ No newline at end of file diff --git a/lib/settings.js b/lib/settings.js index 8bc1db2..6ca9208 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -917,6 +917,18 @@ exports.markets_page = { // Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH" "trading_pairs": [ "LTC/BTC" ] }, + // xeggex: a collection of settings that pertain to the xeggex exchange + // NOTE: xeggex does not display a 24-hour chart due to a lack of OHLCV api data + "xeggex": { + // enabled: Enable/disable the xeggex exchange (true/false) + // If set to false, the xeggex 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" ] + }, // yobit: a collection of settings that pertain to the yobit exchange // NOTE: yobit does not display a 24-hour chart due to a lack of OHLCV api data "yobit": { @@ -929,19 +941,6 @@ exports.markets_page = { // Ex: "LTC/BTC", "LTC/USDT", "LTC/ETH" "trading_pairs": [ "LTC/BTC" ] } - }, - // xeggex: a collection of settings that pertain to the xeggex exchange - // NOTE: xeggex does not display a 24-hour chart due to a lack of OHLCV api data - "xeggex": { - // enabled: Enable/disable the xeggex exchange (true/false) - // If set to false, the xeggex 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" - } }, // default_exchange: a collection of settings that pertain to the default exchange // When the "show_market_dropdown_menu" setting is disabled, the market header menu will navigate directly to the default exchange page @@ -2062,4 +2061,4 @@ Object.byString = function(o, s) { } // populate settings -exports.loadSettings(); +exports.loadSettings(); \ No newline at end of file diff --git a/settings.json.template b/settings.json.template index 7109de9..32d22fe 100644 --- a/settings.json.template +++ b/settings.json.template @@ -1011,9 +1011,8 @@ // 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" - } - }, + "trading_pairs": [ "LTC/USDT" ] + }, // yobit: a collection of settings that pertain to the yobit exchange // NOTE: yobit does not display a 24-hour chart due to a lack of OHLCV api data "yobit": { @@ -1599,4 +1598,4 @@ "enabled": false } } -} +} \ No newline at end of file