diff --git a/src/routes/etf/[tickerID]/+layout.svelte b/src/routes/etf/[tickerID]/+layout.svelte index 22c744ad..456ee4c4 100644 --- a/src/routes/etf/[tickerID]/+layout.svelte +++ b/src/routes/etf/[tickerID]/+layout.svelte @@ -64,11 +64,7 @@ options: "/options", "dark-pool": "/dark-pool", dividends: "/dividends", - statistics: "/statistics", - metrics: "metrics", - forecast: "/forecast", - financials: "/financials", - news: "/news", + history: "/history", }; if (state !== "overview" && sectionMap[state]) { @@ -280,6 +276,7 @@ "dark-pool": "dark-pool", insider: "insider", dividends: "dividends", + history: "history", }; displaySection = sectionMap[ @@ -734,6 +731,16 @@ > Dividends + changeSection("history")} + class="p-2 px-5 cursor-pointer {displaySection === + 'history' + ? 'text-white bg-secondary sm:hover:bg-opacity-[0.95]' + : 'text-gray-400 sm:hover:text-white sm:hover:bg-secondary sm:hover:bg-opacity-[0.95]'}" + > + History + diff --git a/src/routes/etf/[tickerID]/history/+page.server.ts b/src/routes/etf/[tickerID]/history/+page.server.ts new file mode 100644 index 00000000..b6f18331 --- /dev/null +++ b/src/routes/etf/[tickerID]/history/+page.server.ts @@ -0,0 +1,25 @@ +export const load = async ({ locals, params }) => { + const { apiKey, apiURL } = locals; + const getData = 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 { + getData: await getData(), + }; +}; diff --git a/src/routes/etf/[tickerID]/history/+page.svelte b/src/routes/etf/[tickerID]/history/+page.svelte new file mode 100644 index 00000000..6db272f3 --- /dev/null +++ b/src/routes/etf/[tickerID]/history/+page.svelte @@ -0,0 +1,616 @@ + + + + + + + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} + {$displayCompanyName} ({$etfTicker}) Historical Stock Price Data · Stocknear + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+

+ {$etfTicker} Stock Price History +

+
+
+ + + + + + + Select time frame + + + + (timePeriod = "Daily")} + class="cursor-pointer hover:bg-primary" + > + Daily + + (timePeriod = "Weekly")} + class="cursor-pointer hover:bg-primary" + > + Weekly + + {#if data?.user?.tier !== "Pro"} + {#each ["Monthly", "Quarterly", "Annual"] as entry} + goto("/pricing")} + class="cursor-pointer hover:bg-primary" + > + {entry} + + + {/each} + {:else} + (timePeriod = "Monthly")} + class="cursor-pointer hover:bg-primary" + > + Monthly + + (timePeriod = "Quarterly")} + class="cursor-pointer hover:bg-primary" + > + Quarterly + + (timePeriod = "Annual")} + class="cursor-pointer hover:bg-primary" + > + Annual + + {/if} + + + +
+ + +
+
+ {#if isLoaded} + {#if rawData?.length !== 0} +
+
+ + + + + + + {#each stockList as item, index} + + + + + + + + + + + {/each} + +
+ {#if timePeriod === "Weekly"} + Week of {new Date(item?.time).toLocaleString( + "en-US", + { + month: "short", + day: "numeric", + year: "numeric", + daySuffix: "2-digit", + }, + )} + {:else} + {new Date(item?.time).toLocaleString("en-US", { + month: "short", + day: "numeric", + year: "numeric", + daySuffix: "2-digit", + })} + {/if} + + {item?.open?.toFixed(2)} + + {item?.high?.toFixed(2)} + + {item?.low?.toFixed(2)} + + {item?.close?.toFixed(2)} + + {item?.change !== null ? item?.change : "n/a"} + + {item?.changesPercentage !== null + ? item?.changesPercentage + "%" + : "n/a"} + + {item?.volume?.toLocaleString("en-US")} +
+
+
+ {:else} + + {/if} + {:else} +
+
+ +
+
+ {/if} +
+
+ +
+
+
+
diff --git a/src/routes/stocks/[tickerID]/history/+page.svelte b/src/routes/stocks/[tickerID]/history/+page.svelte index a07e7cc7..435a82ac 100644 --- a/src/routes/stocks/[tickerID]/history/+page.svelte +++ b/src/routes/stocks/[tickerID]/history/+page.svelte @@ -278,21 +278,22 @@ {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} - {$displayCompanyName} ({$stockTicker}) Holdings List · Stocknear + {$displayCompanyName} ({$stockTicker}) Historical Stock Price Data · + Stocknear @@ -301,11 +302,11 @@