diff --git a/src/routes/etf/[tickerID]/options/+layout.svelte b/src/routes/etf/[tickerID]/options/+layout.svelte index 8c2a3078..b6aa18a6 100644 --- a/src/routes/etf/[tickerID]/options/+layout.svelte +++ b/src/routes/etf/[tickerID]/options/+layout.svelte @@ -11,6 +11,7 @@ const subSectionMap = { overview: "/options", "hottest-contracts": "/options/hottest-contracts", + "unusual-activity": "/options/unusual-activity", volatility: "/options/volatility", gex: "/options/gex", dex: "/options/dex", @@ -19,10 +20,10 @@ if (state !== "overview" && subSectionMap[state]) { displaySubSection = state; - //goto(`/stocks/${$etfTicker}${subSectionMap[state]}`); + //goto(`/etf/${$etfTicker}${subSectionMap[state]}`); } else { displaySubSection = state; - //goto(`/stocks/${$etfTicker}/statistics`); + //goto(`/etf/${$etfTicker}/statistics`); } } @@ -32,6 +33,7 @@ const sectionMap = { overview: "overview", "hottest-contracts": "hottest-contracts", + "unusual-activity": "unusual-activity", volatility: "volatility", gex: "gex", dex: "dex", @@ -70,7 +72,16 @@ > Overview - + changeSubSection("unusual-activity")} + class="p-2 px-5 cursor-pointer {displaySubSection === + 'unusual-activity' + ? 'text-white bg-primary sm:hover:bg-opacity-[0.95]' + : 'text-gray-400 sm:hover:text-white sm:hover:bg-primary sm:hover:bg-opacity-[0.95]'}" + > + Unusual Activity + changeSubSection("hottest-contracts")} @@ -161,7 +172,7 @@ - Build your Stock Screener to find profitable stocks. + Build your Stock Screener to find profitable etf. diff --git a/src/routes/etf/[tickerID]/options/unusual-activity/+page.server.ts b/src/routes/etf/[tickerID]/options/unusual-activity/+page.server.ts new file mode 100644 index 00000000..2125234f --- /dev/null +++ b/src/routes/etf/[tickerID]/options/unusual-activity/+page.server.ts @@ -0,0 +1,49 @@ + + +export const load = async ({ locals, params }) => { + const { apiKey, apiURL, user } = locals; + + const getData = async () => { + const postData = { + ticker: params.tickerID, + }; + + const response = await fetch(apiURL + "/unusual-activity", { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-API-KEY": apiKey, + }, + body: JSON.stringify(postData), + }); + + let output = await response.json(); + return output; + }; + + const getHistoricalPrice = async () => { + const postData = { ticker: params.tickerID, timePeriod: "six-months" }; + 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(), + getHistoricalPrice: await getHistoricalPrice(), + }; +}; + + diff --git a/src/routes/etf/[tickerID]/options/unusual-activity/+page.svelte b/src/routes/etf/[tickerID]/options/unusual-activity/+page.svelte new file mode 100644 index 00000000..465d5fd9 --- /dev/null +++ b/src/routes/etf/[tickerID]/options/unusual-activity/+page.svelte @@ -0,0 +1,37 @@ + + + + +
+
+
+ {#if data?.getData?.length > 0} + + {:else} +
+
+ +
+
+ {/if} +
+
+