diff --git a/src/routes/stocks/[tickerID]/forecast/+page.svelte b/src/routes/stocks/[tickerID]/forecast/+page.svelte index 119ad786..e5705555 100644 --- a/src/routes/stocks/[tickerID]/forecast/+page.svelte +++ b/src/routes/stocks/[tickerID]/forecast/+page.svelte @@ -14,6 +14,27 @@ let changeEBITDA = 0; let changeEPS = 0; + const price = data?.getStockQuote?.price?.toFixed(2) || 0; + + const calculatePriceChange = (targetPrice) => + targetPrice && price ? ((targetPrice / price - 1) * 100)?.toFixed(2) : 0; + + const numOfAnalyst = data?.getAnalystRating?.numOfAnalyst || 0; + const avgPriceTarget = data?.getAnalystRating?.avgPriceTarget || 0; + const medianPriceTarget = data?.getAnalystRating?.medianPriceTarget || 0; + const lowPriceTarget = data?.getAnalystRating?.lowPriceTarget || 0; + const highPriceTarget = data?.getAnalystRating?.highPriceTarget || 0; + const consensusRating = data?.getAnalystRating?.consensusRating; + + const lowChange = calculatePriceChange(lowPriceTarget); + const medianChange = calculatePriceChange(medianPriceTarget); + const avgChange = calculatePriceChange(avgPriceTarget); + const highChange = calculatePriceChange(highPriceTarget); + const rawAnalystList = data?.getAnalystRating?.recommendationList || []; + const recommendationList = + rawAnalystList?.length > 5 ? rawAnalystList?.slice(-6, -1) : rawAnalystList; + const categories = ["Strong Buy", "Buy", "Hold", "Sell", "Strong Sell"]; + function findIndex(data) { const currentYear = new Date().getFullYear(); @@ -35,6 +56,13 @@ return index; // Return the index or -1 if not found } + function getTotalForDate(index) { + return categories.reduce( + (sum, cat) => sum + recommendationList[index][cat], + 0, + ); + } + const calculateChange = (current, previous) => { if (previous !== undefined && previous !== 0) { const change = (Math.abs(current) / Math.abs(previous) - 1) * 100; @@ -115,24 +143,29 @@
-
-
+
+

+ {$displayCompanyName} Forcast +

+
-
+

Stock Price Forecast

- The 15 analysts with 12-month price forecasts for SMCI stock - have an average target of 74.53, with a low estimate of 32.5 - and a high estimate of 135. The average target predicts an - increase of 125.37% from the current stock price of 33.07. + The {numOfAnalyst} analysts with 12-month price forecasts for {$stockTicker} + stock have an median target of {medianPriceTarget}, with a low + estimate of {lowPriceTarget} + and a high estimate of {highPriceTarget}. The median target + predicts an increase of {medianChange}% from the current stock + price of {price}.

@@ -145,8 +178,14 @@ >
- Analyst Consensus: Buy{consensusRating}
@@ -162,7 +201,6 @@
- - ${lowPriceTarget} + + - - 0 + ? "before:content-['+'] text-[#00FC50]" + : "text-[#FF2F1F]"}>{lowChange}% - 0 + ? "before:content-['+'] text-[#00FC50]" + : "text-[#FF2F1F]"}>{avgChange}% - 0 + ? "before:content-['+'] text-[#00FC50]" + : "text-[#FF2F1F]"}>{lowChange}% + @@ -202,12 +251,94 @@ -

+
+
+
+

Analyst Ratings

+

+ According to {numOfAnalyst} stock analyst, the rating for GameStop + is "{consensusRating}". This means that the analyst believes + this stock is likely to lead to {[ + "Strong Sell", + "Sell", + ]?.includes(consensusRating) + ? "lower" + : ["Strong Buy", "Buy"]?.includes(consensusRating) + ? "higher" + : "similar"} returns than market as a whole. +

+
+
+
+
+ +
+
+

Price$32.5 $74.53 $67.5$135
${avgPriceTarget} ${medianPriceTarget}${highPriceTarget}
Change-1.72%+125.37%+104.11%+308.22% 0 + ? "before:content-['+'] text-[#00FC50]" + : "text-[#FF2F1F]"}>{highChange}%
+ + {#each recommendationList as item} + + {/each} + + + {#each categories as category} + + + {#each recommendationList as entry} + + {/each} + + {/each} + + + {#each recommendationList as _, i} + + {/each} + + +
Rating{new Intl.DateTimeFormat("en", { + month: "short", + year: "2-digit", + }).format(new Date(item?.date))}
{category}{entry[category]}
Total + {getTotalForDate(i)} +
+
+
+
+ +

Financial Forecast this Year

{#if data?.getAnalystEstimate?.length !== 0}