diff --git a/src/lib/components/RetailVolume.svelte b/src/lib/components/RetailVolume.svelte index df476d0f..4ef4d4d9 100644 --- a/src/lib/components/RetailVolume.svelte +++ b/src/lib/components/RetailVolume.svelte @@ -11,6 +11,7 @@ let isLoaded = false; const usRegion = ['cle1','iad1','pdx1','sfo1']; + let historyData = []; let apiURL; userRegion.subscribe(value => { @@ -49,7 +50,7 @@ function getPlotOptions() { let tradingList = []; let sentimentList = []; // Iterate over the data and extract required information - rawData?.forEach(item => { + historyData?.forEach(item => { dates?.push(item?.date); tradingList?.push(item?.traded); @@ -164,6 +165,7 @@ const getRetailVolume = async (ticker) => { const cachedData = getCache(ticker, 'getRetailVolume'); if (cachedData) { rawData = cachedData; + historyData = rawData?.history; } else { const postData = {'ticker': ticker}; @@ -177,11 +179,11 @@ const getRetailVolume = async (ticker) => { }); rawData = await response.json(); - + historyData = rawData?.history; // Cache the data for this specific tickerID with a specific name 'getRetailVolume' setCache(ticker, rawData, 'getRetailVolume'); } - if(rawData?.length !== 0) { + if(Object?.keys(rawData)?.length !== 0) { $retailVolumeComponent = true; } else { $retailVolumeComponent = false; @@ -216,11 +218,11 @@ $: {
| - {new Date(rawData?.slice(-1)?.at(0)?.date)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} + {new Date(rawData?.lastDate)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} | ||
| - {abbreviateNumber(rawData?.slice(-1)?.at(0)?.traded,true)} + {abbreviateNumber(rawData?.lastTrade,true)} | ||
| Retail Sentiment | -- {rawData?.slice(-1)?.at(0)?.sentiment > 0 ? rawData?.slice(-1)?.at(0)?.sentimentt+' '+'(Bullish)' : rawData?.slice(-1)?.at(0)?.sentiment+' '+'(Bearish)'} + | + {rawData?.lastSentiment >=0 ? rawData?.lastSentiment+' '+'(Bullish)' : rawData?.lastSentiment +' '+'(Bearish)'} |