From 8ead3b247397415cad9aec80f6a1b455a3b4ff40 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 4 Nov 2024 20:08:28 +0100 Subject: [PATCH] bugfixing: price target --- .../[tickerID]/forecast/analyst/+page.svelte | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte b/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte index 2cd62233..0cc5cde2 100644 --- a/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte +++ b/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte @@ -42,8 +42,14 @@ : "-"; consensusRating = analystRating?.consensusRating; changesPercentage = - analystRating?.priceTarget !== ("n/a" && 0) - ? ((priceTarget / data?.getStockQuote?.price - 1) * 100)?.toFixed(2) + analystRating?.medianPriceTarget !== "n/a" && + analystRating?.medianPriceTarget !== null && + analystRating?.medianPriceTarget !== undefined && + data?.getStockQuote?.price !== null + ? ( + (analystRating.medianPriceTarget / data.getStockQuote.price - 1) * + 100 + )?.toFixed(2) : "-"; } if (activeIdx === 1) { @@ -220,7 +226,9 @@
- ${priceTarget} + {priceTarget !== null && priceTarget !== undefined + ? "$" + priceTarget + : "n/a"}
- {changesPercentage}% + {changesPercentage}