From fa737e8cb2d7a0b2e2fc674ea15525cd76e9311d Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Tue, 23 Apr 2024 14:32:20 +0100 Subject: [PATCH 1/3] CL-1406: Removing full_name from symbol --- src/datafeed.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/datafeed.js b/src/datafeed.js index 2839787..8cf480a 100644 --- a/src/datafeed.js +++ b/src/datafeed.js @@ -50,7 +50,6 @@ async function getAllSymbols() { const symbol = generateSymbol(exchange.value, leftPairPart, rightPairPart); return { symbol: symbol.short, - full_name: symbol.full, description: symbol.short, exchange: exchange.value, type: 'crypto', @@ -78,7 +77,8 @@ export default { const symbols = await getAllSymbols(); const newSymbols = symbols.filter(symbol => { const isExchangeValid = exchange === '' || symbol.exchange === exchange; - const isFullSymbolContainsInput = symbol.full_name + const fullName = `${symbol.exchange}:${symbol.symbol}`; + const isFullSymbolContainsInput = fullName .toLowerCase() .indexOf(userInput.toLowerCase()) !== -1; return isExchangeValid && isFullSymbolContainsInput; @@ -95,8 +95,12 @@ export default { console.log('[resolveSymbol]: Method call', symbolName); const symbols = await getAllSymbols(); const symbolItem = symbols.find(({ - full_name, - }) => full_name === symbolName); + exchange, + symbol + }) => { + const fullName = `${exchange}:${symbol}`; + return fullName === symbolName + }); if (!symbolItem) { console.log('[resolveSymbol]: Cannot resolve symbol', symbolName); onResolveErrorCallback('cannot resolve symbol'); @@ -104,7 +108,7 @@ export default { } // Symbol information object const symbolInfo = { - ticker: symbolItem.full_name, + ticker: symbolItem.symbol, name: symbolItem.symbol, description: symbolItem.description, type: symbolItem.type, From c33d85d514f6778f4e4b2a73e802f546b74d7477 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Wed, 15 May 2024 14:03:48 +0100 Subject: [PATCH 2/3] CL-1406: adding missing property ticker --- src/datafeed.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/datafeed.js b/src/datafeed.js index 8cf480a..cc93c32 100644 --- a/src/datafeed.js +++ b/src/datafeed.js @@ -50,6 +50,7 @@ async function getAllSymbols() { const symbol = generateSymbol(exchange.value, leftPairPart, rightPairPart); return { symbol: symbol.short, + ticker: symbol.short, description: symbol.short, exchange: exchange.value, type: 'crypto', @@ -77,7 +78,7 @@ export default { const symbols = await getAllSymbols(); const newSymbols = symbols.filter(symbol => { const isExchangeValid = exchange === '' || symbol.exchange === exchange; - const fullName = `${symbol.exchange}:${symbol.symbol}`; + const fullName = `${symbol.exchange}:${symbol.ticker}`; const isFullSymbolContainsInput = fullName .toLowerCase() .indexOf(userInput.toLowerCase()) !== -1; @@ -96,9 +97,9 @@ export default { const symbols = await getAllSymbols(); const symbolItem = symbols.find(({ exchange, - symbol + ticker }) => { - const fullName = `${exchange}:${symbol}`; + const fullName = `${exchange}:${ticker}`; return fullName === symbolName }); if (!symbolItem) { @@ -108,7 +109,7 @@ export default { } // Symbol information object const symbolInfo = { - ticker: symbolItem.symbol, + ticker: symbolItem.ticker, name: symbolItem.symbol, description: symbolItem.description, type: symbolItem.type, From aba216bbe3334d803a29a1035ed418dbb51c0044 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Thu, 16 May 2024 15:57:29 +0100 Subject: [PATCH 3/3] CL-1406: Slight refactoring --- src/datafeed.js | 6 +----- src/helpers.js | 1 - src/main.js | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/datafeed.js b/src/datafeed.js index cc93c32..d104818 100644 --- a/src/datafeed.js +++ b/src/datafeed.js @@ -96,12 +96,8 @@ export default { console.log('[resolveSymbol]: Method call', symbolName); const symbols = await getAllSymbols(); const symbolItem = symbols.find(({ - exchange, ticker - }) => { - const fullName = `${exchange}:${ticker}`; - return fullName === symbolName - }); + }) => ticker === symbolName); if (!symbolItem) { console.log('[resolveSymbol]: Cannot resolve symbol', symbolName); onResolveErrorCallback('cannot resolve symbol'); diff --git a/src/helpers.js b/src/helpers.js index d6520ba..7d5e6d1 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -18,7 +18,6 @@ export function generateSymbol(exchange, fromSymbol, toSymbol) { const short = `${fromSymbol}/${toSymbol}`; return { short, - full: `${exchange}:${short}`, }; } diff --git a/src/main.js b/src/main.js index 677eb1f..7f87bfc 100644 --- a/src/main.js +++ b/src/main.js @@ -2,7 +2,7 @@ import Datafeed from './datafeed.js'; window.tvWidget = new TradingView.widget({ - symbol: 'Bitfinex:BTC/USD', // Default symbol + symbol: 'BTC/EUR', // Default symbol interval: '1D', // Default interval fullscreen: true, // Displays the chart in the fullscreen mode container: 'tv_chart_container', // Reference to an attribute of the DOM element