From 724d41a13d32fc1460dabae5451709d1540b2802 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 15 Jan 2025 00:23:35 +0100 Subject: [PATCH] add volatility to etf page --- .../etf/[tickerID]/options/+layout.svelte | 12 ++++ .../options/volatility/+layout.svelte | 15 ++++ .../options/volatility/+page.server.ts | 31 ++++++++ .../options/volatility/+page.svelte | 70 +++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 src/routes/etf/[tickerID]/options/volatility/+layout.svelte create mode 100644 src/routes/etf/[tickerID]/options/volatility/+page.server.ts create mode 100644 src/routes/etf/[tickerID]/options/volatility/+page.svelte diff --git a/src/routes/etf/[tickerID]/options/+layout.svelte b/src/routes/etf/[tickerID]/options/+layout.svelte index abb96dc0..acbf95c7 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", + volatility: "/options/volatility", gex: "/options/gex", dex: "/options/dex", oi: "/options/oi", @@ -31,6 +32,7 @@ const sectionMap = { overview: "overview", "hottest-contracts": "hottest-contracts", + volatility: "volatility", gex: "gex", dex: "dex", oi: "oi", @@ -79,6 +81,16 @@ > Hottest Contracts + changeSubSection("volatility")} + class="p-2 px-5 cursor-pointer {displaySubSection === + 'volatility' + ? '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]'}" + > + Volatility + changeSubSection("oi")} diff --git a/src/routes/etf/[tickerID]/options/volatility/+layout.svelte b/src/routes/etf/[tickerID]/options/volatility/+layout.svelte new file mode 100644 index 00000000..22ee866b --- /dev/null +++ b/src/routes/etf/[tickerID]/options/volatility/+layout.svelte @@ -0,0 +1,15 @@ +
+
+
+
+
+
+ +
+
+
+
+
+
diff --git a/src/routes/etf/[tickerID]/options/volatility/+page.server.ts b/src/routes/etf/[tickerID]/options/volatility/+page.server.ts new file mode 100644 index 00000000..2deabb8c --- /dev/null +++ b/src/routes/etf/[tickerID]/options/volatility/+page.server.ts @@ -0,0 +1,31 @@ + + +export const load = async ({ locals, params }) => { + const { apiKey, apiURL, user } = locals; + + const getData = async () => { + const postData = { + ticker: params.tickerID, + }; + + const response = await fetch(apiURL + "/implied-volatility", { + 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]/options/volatility/+page.svelte b/src/routes/etf/[tickerID]/options/volatility/+page.svelte new file mode 100644 index 00000000..297ebfb5 --- /dev/null +++ b/src/routes/etf/[tickerID]/options/volatility/+page.svelte @@ -0,0 +1,70 @@ + + + + + + + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} + {$displayCompanyName} ({$etfTicker}) Volatility · Stocknear + + + + + + + + + + + + + + + + +
+
+
+ {#if data?.getData?.length > 0} + + {:else} +
+
+ +
+
+ {/if} +
+
+