From 67551ae6b2933851f2f3fa7b101df73932ace03d Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Fri, 25 Oct 2024 20:38:47 +0200 Subject: [PATCH] update options page --- src/lib/components/OptionsNetFlow.svelte | 434 ++++++++---------- .../stocks/[tickerID]/options/+page.server.ts | 24 +- .../stocks/[tickerID]/options/+page.svelte | 12 +- .../stocks/[tickerID]/statistics/+page.svelte | 12 +- 4 files changed, 228 insertions(+), 254 deletions(-) diff --git a/src/lib/components/OptionsNetFlow.svelte b/src/lib/components/OptionsNetFlow.svelte index 8afbc4a0..726b820f 100644 --- a/src/lib/components/OptionsNetFlow.svelte +++ b/src/lib/components/OptionsNetFlow.svelte @@ -1,266 +1,214 @@ - - - -
-
- -
- - -
- - {#if isLoaded} - - {#if rawData?.length !== 0} - + }); + + +
+
+
+ + +
+ + {#if isLoaded} + {#if rawData?.length !== 0}
-
- The options net flow demonstrates a {sentiment} trend in the last 2 trading hours, characterized by the {sentiment === 'bullish' ? 'Net Call Flow exceeding the Net Put Flow' : 'Net Put Flow exceeding the Net Call Flow'}. -
+
+ The options net flow demonstrates a {sentiment} trend in the last 2 trading + hours, characterized by the {sentiment === "bullish" + ? "Net Call Flow exceeding the Net Put Flow" + : "Net Put Flow exceeding the Net Call Flow"}. +
- +
- - -
- -
- +
+ +
- -
- -
- - - - Net Call - -
-
- - - - Net Put - -
- -
- - - {/if} - - {:else} -
-
- -
-
- {/if} - +
+
+ + + + Net Call + +
- -
-
- - - - - \ No newline at end of file + diff --git a/src/routes/stocks/[tickerID]/options/+page.server.ts b/src/routes/stocks/[tickerID]/options/+page.server.ts index 1bb17d33..82b97915 100644 --- a/src/routes/stocks/[tickerID]/options/+page.server.ts +++ b/src/routes/stocks/[tickerID]/options/+page.server.ts @@ -1,4 +1,23 @@ export const load = async ({ locals, params }) => { + const getOptionsNetFlow = async () => { + const postData = { + ticker: params.tickerID, + }; + + const response = await fetch(locals?.apiURL + "/options-net-flow-ticker", { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-API-KEY": locals?.apiKey, + }, + body: JSON.stringify(postData), + }); + + const output = await response.json(); + + return output; + }; + const getOptionsPlotData = async () => { const postData = { ticker: params.tickerID, @@ -33,7 +52,7 @@ export const load = async ({ locals, params }) => { "X-API-KEY": locals?.apiKey, }, body: JSON.stringify(postData), - } + }, ); const output = await response.json(); @@ -56,7 +75,7 @@ export const load = async ({ locals, params }) => { "X-API-KEY": locals?.apiKey, }, body: JSON.stringify(postData), - } + }, ); const output = await response.json(); @@ -86,6 +105,7 @@ export const load = async ({ locals, params }) => { // Make sure to return a promise return { + getOptionsNetFlow: await getOptionsNetFlow(), getOptionsPlotData: await getOptionsPlotData(), getOptionsHistoricalData: await getOptionsHistoricalData(), getOptionsChainData: await getOptionsChainData(), diff --git a/src/routes/stocks/[tickerID]/options/+page.svelte b/src/routes/stocks/[tickerID]/options/+page.svelte index c0820002..7036537c 100644 --- a/src/routes/stocks/[tickerID]/options/+page.svelte +++ b/src/routes/stocks/[tickerID]/options/+page.svelte @@ -561,9 +561,15 @@ >
-

- Unsual Options Activity -

+
+ {#await import("$lib/components/OptionsNetFlow.svelte") then { default: Comp }} + + {/await} +
Shares Outstanding 3.19B Shares Change (YoY) +0.31% Shares Change (QoQ) +0.46% Owned by Insiders (%) 12.96% Owned by Institutions (%) 45.99% Float 2.78B