From f58b8ad5aa77b4f1941d2f0035c588743f860c99 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Tue, 27 Aug 2024 09:50:42 +0200 Subject: [PATCH] update VaR component --- src/lib/components/VaR.svelte | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/components/VaR.svelte b/src/lib/components/VaR.svelte index 017d14da..0e40564c 100644 --- a/src/lib/components/VaR.svelte +++ b/src/lib/components/VaR.svelte @@ -21,7 +21,7 @@ export let data; let valueAtRisk; let varDict = {} let optionsData; - + let monthlyVarAvg; function getPlotOptions() { let dates = []; @@ -33,6 +33,12 @@ function getPlotOptions() { varList?.push(item?.var); }); + const sum = varList.reduce((accumulator, currentValue) => { + return accumulator + currentValue; + }, 0); + + monthlyVarAvg = (sum / varList?.length)?.toFixed(2); + const option = { silent: true, @@ -213,7 +219,13 @@ function getPlotOptions() { - +

+ Historical VaR +

+
+ Based on historical price data, the company experienced an average monthly Value at Risk (VaR) of {monthlyVarAvg}%. +
+