From aaf2d14868f4a3a7372d2e8652b3e8e0be48272f Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 18 Sep 2024 18:00:49 +0200 Subject: [PATCH] update failtodeliver component --- src/lib/components/FailToDeliver.svelte | 30 +++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/lib/components/FailToDeliver.svelte b/src/lib/components/FailToDeliver.svelte index 801ab5bc..9d5e1067 100644 --- a/src/lib/components/FailToDeliver.svelte +++ b/src/lib/components/FailToDeliver.svelte @@ -16,13 +16,12 @@ let isLoaded = false; - let rawData = []; let optionsData; let avgFailToDeliver; let lowestPrice; let highestPrice; - + let weightedFTD; function findLowestAndHighestPrice(data, lastDateStr) { @@ -212,7 +211,10 @@ function findLowestAndHighestPrice(data, lastDateStr) { ]; Promise.all(asyncFunctions) .then((results) => { - optionsData = getPlotOptions() + if(rawData?.length !== 0) { + weightedFTD = ((rawData?.slice(-1)?.at(0)?.failToDeliver/data?.getStockQuote?.avgVolume) * 100)?.toFixed(2); + optionsData = getPlotOptions() + } }) .catch((error) => { console.error('An error occurred:', error); @@ -222,19 +224,7 @@ function findLowestAndHighestPrice(data, lastDateStr) { } } - let charNumber = 20; - - $: { - if($screenWidth < 640) - { - charNumber = 20; - } - else { - charNumber =40; - } - } - - + let charNumber = $screenWidth < 640 ? 20 : 40; @@ -330,7 +320,13 @@ function findLowestAndHighestPrice(data, lastDateStr) { - +
+
+ Using the latest FTD shares data, we calculate the monthly average volume ratio to determine that less than + {weightedFTD < 0.01 ? '< 0.01' : weightedFTD}% of shares failed to deliver. +
+
+ {/if}