From eb4a5d0f8d01353ed76315f683886fccb3b00187 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Tue, 16 Jul 2024 19:03:24 +0200 Subject: [PATCH] bugfixing dark pool component --- src/lib/components/DarkPool.svelte | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/components/DarkPool.svelte b/src/lib/components/DarkPool.svelte index f8e4c6a5..53db5789 100644 --- a/src/lib/components/DarkPool.svelte +++ b/src/lib/components/DarkPool.svelte @@ -27,7 +27,7 @@ let avgVolume; let avgShortVolume; let monthlyVolume; - let monthlyShort; + let avgMonthlyShort; function normalizer(value) { if (Math?.abs(value) >= 1e18) { @@ -65,9 +65,13 @@ function findMonthlyValue(data, lastDateStr) { }, 0)); - monthlyShort = filteredData?.reduce((accumulator, currentItem) => { - return accumulator + currentItem?.shortPercent; - }, 0)?.toFixed(2); + const totalShortPercent = filteredData.reduce((accumulator, currentItem) => { + return accumulator + (currentItem?.shortPercent || 0); + }, 0); + + avgMonthlyShort = (totalShortPercent / filteredData?.length)?.toFixed(2); + + } @@ -297,7 +301,7 @@ $: { - Volume + Total Volume {monthlyVolume} @@ -305,10 +309,10 @@ $: { - Short % of Volume + Avg. Short % of Volume - {monthlyShort}% + {avgMonthlyShort}%