From adbdcf9a42674ce66fdba7a2b3a9caeef887a3a5 Mon Sep 17 00:00:00 2001 From: gh14 Date: Mon, 26 May 2025 08:27:35 +0000 Subject: [PATCH] Add Exbitron API to price feeds. Other minor changes --- lib/market.js | 27 +++++++++++++++++++++++++++ website_example/js/common.js | 12 +++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/market.js b/lib/market.js index 2eb538f..9ac06d9 100644 --- a/lib/market.js +++ b/lib/market.js @@ -137,6 +137,33 @@ function getExchangeMarkets (exchange, callback) { callback(null, data); }, '/v1/ticker'); } +// Exbitron +else if (exchange == "exbitron") { + apiInterfaces.jsonHttpRequest('api.exbitron.digital', 443, '', function (error, response) { + if (error) log('error', logSystem, 'API request to %s has failed: %s', [exchange, error]); + + let data = {}; + if (!error && response && response.status === "OK" && response.data) { + let market = response.data.market; + let pairParts = market.id.split('-'); + let symbol = pairParts[0]; + let target = pairParts[1]; + + let price = +market.marketDynamics.lastPrice; + if (price !== 0) { + if (!data[symbol]) data[symbol] = {}; + data[symbol][target] = price; + } + } + + if (!error) marketRequestsCache[cacheKey] = { + ts: currentTimestamp, + data: data + }; + callback(null, data); + }, '/api/v1/trading/info/' + config.symbol + '-USDT'); +} + // Crex24 else if (exchange == "crex24") { diff --git a/website_example/js/common.js b/website_example/js/common.js index 801cd56..b7cd686 100644 --- a/website_example/js/common.js +++ b/website_example/js/common.js @@ -87,8 +87,12 @@ function routePage(loadedCallback) { $('#loading').hide(); $('#page').show().html(data); loadTranslations(); - if (currentPage) currentPage.update(); - if (loadedCallback) loadedCallback(); + if (currentPage) { + currentPage.update(); + } + if (loadedCallback) { + loadedCallback(); + } } }); } @@ -1247,6 +1251,7 @@ function market_LoadMarketData(api, stats, loadedData, currencyPairs, xhrMarketG // Market data polling (poll data every 5 minutes) function market_UpdateMarkets(api, stats, currencyPairs, xhrMarketGets, marketPrices){ if (typeof marketCurrencies === 'undefined' || marketCurrencies.length === 0) return ; + if (typeof exchangeName === 'undefined' || exchangeName === 0) { let exchangeName = "exbitron" } ; currencyPairs[stats.config.coin] = [] @@ -1258,7 +1263,7 @@ function market_UpdateMarkets(api, stats, currencyPairs, xhrMarketGets, marketPr xhrMarketGets[stats.config.coin] = $.ajax({ url: api + '/get_market', - data: { tickers: currencyPairs[stats.config.coin] }, + data: { tickers: currencyPairs[stats.config.coin], exchange: exchangeName }, dataType: 'json', cache: 'false', success: function(data) { @@ -1318,6 +1323,7 @@ function market_RenderMarketPrice(base, target, price, source, stats, marketPric else if (source == 'cryptopia') sourceURL = 'https://www.cryptopia.co.nz/'; else if (source == 'stocks.exchange') sourceURL = 'https://stocks.exchange/'; else if (source == 'tradeogre') sourceURL = 'https://tradeogre.com/'; + else if (source == 'exbitron') sourceURL = 'https://app.exbitron.com/'; source = source.charAt(0).toUpperCase() + source.slice(1); if (sourceURL) source = ''+source+'';