From defd8a92838a609f77cecfd5a03f0d0b8ba7c1c3 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sat, 31 Aug 2024 13:35:47 +0200 Subject: [PATCH] update forecast overview page --- .../stocks/[tickerID]/forecast/+page.svelte | 92 ++++++++++++++++++- .../stocks/[tickerID]/forecast/+page.ts | 40 ++++---- .../[tickerID]/forecast/analyst/+page.svelte | 2 +- .../stocks/[tickerID]/stats/+page.svelte | 18 +--- 4 files changed, 113 insertions(+), 39 deletions(-) diff --git a/src/routes/stocks/[tickerID]/forecast/+page.svelte b/src/routes/stocks/[tickerID]/forecast/+page.svelte index ed968eee..a0c2199c 100644 --- a/src/routes/stocks/[tickerID]/forecast/+page.svelte +++ b/src/routes/stocks/[tickerID]/forecast/+page.svelte @@ -1,8 +1,20 @@ @@ -31,6 +43,84 @@
+ +

+ Financial Forecast this Year +

+ +
+
+ +
+
+ {abbreviateNumber(data?.getAnalystEstimate[index-1]?.estimatedRevenueAvg,true)} +
+
+ + {changeRevenue}% +
+
+
+ from {abbreviateNumber(data?.getAnalystEstimate[index-2]?.revenue)} +
+
+
+ +
+
+ {abbreviateNumber(data?.getAnalystEstimate[index-1]?.estimatedNetIncomeAvg,true)} +
+
+ + {changeNetIncome}% +
+
+
+ from {abbreviateNumber(data?.getAnalystEstimate[index-2]?.netIncome,true)} +
+
+
+ +
+
+ {abbreviateNumber(data?.getAnalystEstimate[index-1]?.estimatedEbitdaAvg,true)} +
+
+ + {changeEBITDA}% +
+
+
+ from {abbreviateNumber(data?.getAnalystEstimate[index-2]?.ebitda,true)} +
+
+
+ +
+
+ {data?.getAnalystEstimate[index-1]?.estimatedEpsAvg} +
+
+ + {changeEPS}% +
+
+
+ from {data?.getAnalystEstimate[index-2]?.eps} +
+
+
+ + +
{#await import("$lib/components/AnalystEstimate.svelte") then { default: Comp }} diff --git a/src/routes/stocks/[tickerID]/forecast/+page.ts b/src/routes/stocks/[tickerID]/forecast/+page.ts index 095a324c..337a6577 100644 --- a/src/routes/stocks/[tickerID]/forecast/+page.ts +++ b/src/routes/stocks/[tickerID]/forecast/+page.ts @@ -1,36 +1,32 @@ -import { getCache, setCache } from '$lib/store'; - +import { getCache, setCache } from "$lib/store"; export const load = async ({ parent, params }) => { - - const getAnalystTickerHistory = async () => { - + const getAnalystEstimate = async () => { let output; - const cachedData = getCache(params.tickerID, 'getAnalystTickerHistory'); - if (cachedData) { - output = cachedData; - } else { + const cachedData = getCache(params.tickerID, "getAnalystEstimate"); + if (cachedData) { + output = cachedData; + } else { + const { apiURL, apiKey } = await parent(); - const {apiURL, apiKey} = await parent(); - - const postData = { - ticker: params.tickerID - }; + const postData = { + ticker: params.tickerID, + }; // make the POST request to the endpoint - const response = await fetch(apiURL + '/analyst-ticker-history', { - method: 'POST', + const response = await fetch(apiURL + "/analyst-estimate", { + method: "POST", headers: { - "Content-Type": "application/json", "X-API-KEY": apiKey + "Content-Type": "application/json", + "X-API-KEY": apiKey, }, - body: JSON.stringify(postData) + body: JSON.stringify(postData), }); - output = await response.json(); + output = await response.json(); - setCache(params.tickerID, output, 'getAnalystTickerHistory'); - + setCache(params.tickerID, output, "getAnalystEstimate"); } return output; @@ -38,6 +34,6 @@ export const load = async ({ parent, params }) => { // Make sure to return a promise return { - getAnalystTickerHistory: await getAnalystTickerHistory() + getAnalystEstimate: await getAnalystEstimate(), }; }; diff --git a/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte b/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte index 523790de..af5a5398 100644 --- a/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte +++ b/src/routes/stocks/[tickerID]/forecast/analyst/+page.svelte @@ -190,7 +190,7 @@ changeTab(0) {/if}
-
+
diff --git a/src/routes/stocks/[tickerID]/stats/+page.svelte b/src/routes/stocks/[tickerID]/stats/+page.svelte index 8376d055..3420a2e7 100644 --- a/src/routes/stocks/[tickerID]/stats/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/+page.svelte @@ -3,21 +3,12 @@ import ReturnCard from "$lib/components/ReturnCard.svelte"; import { numberOfUnreadNotification, displayCompanyName, screenWidth, stockTicker, revenueSegmentationComponent } from "$lib/store"; import { abbreviateNumber } from "$lib/utils"; + import RevenueSegmentation from "$lib/components/RevenueSegmentation.svelte"; export let data; let quantStats = {}; - let stockQuote; - let marketCap = "-"; - - let currentPrice = 0; - let previousClose = "-"; - let volume = "-"; - let eps = "-"; - let pe = "-"; - let alpha = "-"; - let beta = "-"; // Function to check if a date is today or yesterday, adjusting for weekends function ongoingDD(dateString: string) { @@ -75,7 +66,6 @@ if (progressYearPriceValue < currentPrice) { - stockQuote = data?.getStockQuote; quantStats = data?.getQuantStats ?? {}; @@ -218,9 +208,7 @@ updateYearRange()
- {#await import("$lib/components/RevenueSegmentation.svelte") then { default: Comp }} - - {/await} +
@@ -230,7 +218,7 @@ updateYearRange() {#if $stockTicker in quantStats && Object.keys(quantStats[$stockTicker]).length > 0} -

+

Worst 10 Drawdowns of {$stockTicker}