diff --git a/src/routes/stocks/[tickerID]/forecast/ai/+layout.svelte b/src/routes/stocks/[tickerID]/forecast/ai/+layout.svelte new file mode 100644 index 00000000..3e3e8ddb --- /dev/null +++ b/src/routes/stocks/[tickerID]/forecast/ai/+layout.svelte @@ -0,0 +1,59 @@ + + +
+
+
+
+
+ +
+ + +
+
+
+
diff --git a/src/routes/stocks/[tickerID]/forecast/ai/+page.server.ts b/src/routes/stocks/[tickerID]/forecast/ai/+page.server.ts index 3787f9b6..1c538d39 100644 --- a/src/routes/stocks/[tickerID]/forecast/ai/+page.server.ts +++ b/src/routes/stocks/[tickerID]/forecast/ai/+page.server.ts @@ -23,10 +23,27 @@ export const load = async ({ locals, params }) => { return output; }; + const getHistoricalPrice = async () => { + const postData = { ticker: params.tickerID, timePeriod: "max" }; + const response = await fetch(apiURL + "/historical-price", { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-API-KEY": apiKey, + }, + body: JSON.stringify(postData), + }); + + const output = await response.json(); + + return output; + }; + // Make sure to return a promise return { getPriceAnalysis: await getPriceAnalysis(), + getHistoricalPrice: await getHistoricalPrice(), }; }; diff --git a/src/routes/stocks/[tickerID]/forecast/ai/+page.svelte b/src/routes/stocks/[tickerID]/forecast/ai/+page.svelte index 3e7e0dd6..27a1ed4d 100644 --- a/src/routes/stocks/[tickerID]/forecast/ai/+page.svelte +++ b/src/routes/stocks/[tickerID]/forecast/ai/+page.svelte @@ -1,5 +1,6 @@ @@ -473,114 +487,102 @@ description={`Discover our AI-powered forecast for ${$displayCompanyName} (${$stockTicker}). Get in-depth analyst ratings, price targets, upgrades, and downgrades from top Wall Street experts. Stay ahead of market trends and make smarter investment decisions.`} /> -
-
+
+
-
-

- {$displayCompanyName} AI Forecast -

- {#if Object?.keys(data?.getPriceAnalysis)?.length > 0} -
-
-
-
-
-

Stock Price Forecast

- -
-

- Using our AI model trained on historical data, we generated - a 12‑month forecast for {$displayCompanyName} - ({$stockTicker}) stock. The model estimates a median target - price of {medianPriceTarget}—ranging from a low of {lowPriceTarget} - to a high of {highPriceTarget}—which suggests {medianChange > - 0 - ? "an increase" - : "a decrease"} of {medianChange}% compared to the current - price of {price}. -

-
-
-
-
-
-
-
-
-
-
- - - - - - - - - +
+
+

+ {removeCompanyStrings($displayCompanyName)} Trend Forecast +

+
+ + {#if Object?.keys(data?.getPriceAnalysis)?.length > 0} +
+ 0 ? "an increase" : "a decrease" + } of ${medianChange}% compared to the current price + of ${price}.`} + /> + +
+
+
+ +
+
Target LowAverageMedianHigh
Price${lowPriceTarget}${avgPriceTarget} ${medianPriceTarget}${highPriceTarget}
+ + + + - - + + + + - - - -
Target LowAverageMedianHigh
Change 0 - ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" - : "text-red-600 dark:text-[#FF2F1F]"} - >{lowChange}%
Price${lowPriceTarget}${avgPriceTarget}${medianPriceTarget}${highPriceTarget}
0 - ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" - : "text-red-600 dark:text-[#FF2F1F]"} - >{avgChange}% 0 - ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" - : "text-red-600 dark:text-[#FF2F1F]"} - >{medianChange}% 0 - ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" - : "text-red-600 dark:text-[#FF2F1F]"} - >{highChange}%
+ Change + 0 + ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" + : "text-red-600 dark:text-[#FF2F1F]"} + >{lowChange}% + 0 + ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" + : "text-red-600 dark:text-[#FF2F1F]"} + >{avgChange}% + 0 + ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" + : "text-red-600 dark:text-[#FF2F1F]"} + >{medianChange}% + 0 + ? "before:content-['+'] text-green-600 dark:text-[#00FC50]" + : "text-red-600 dark:text-[#FF2F1F]"} + >{highChange}% + +
-
- {:else} - - {/if} -
+ {:else} + + {/if} +
+