From 40f410d5fbb12b2ba2edc8f59588f506393b4e21 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sun, 16 Feb 2025 18:55:12 +0100 Subject: [PATCH] add ticker flow --- src/lib/components/Options/TickerFlow.svelte | 461 ++++++++++++++++++ .../stocks/[tickerID]/forecast/+layout.svelte | 13 +- .../stocks/[tickerID]/options/+page.server.ts | 21 + .../stocks/[tickerID]/options/+page.svelte | 8 + 4 files changed, 501 insertions(+), 2 deletions(-) create mode 100644 src/lib/components/Options/TickerFlow.svelte diff --git a/src/lib/components/Options/TickerFlow.svelte b/src/lib/components/Options/TickerFlow.svelte new file mode 100644 index 00000000..3faad3b0 --- /dev/null +++ b/src/lib/components/Options/TickerFlow.svelte @@ -0,0 +1,461 @@ + + +
+
+
+
+
+
+ {#if optionsData !== null} + + +
+ Last Updated: {formatDate(findLastNonNull(tickerFlow, "time"))} +
+
+
+
+ Volume + +
+
+ + {@html abbreviateNumberWithColor( + findLastNonNull(tickerFlow, "net_volume"), + false, + true, + )} +
+
+ +
+
+ Net Call Prem + +
+
+ {@html abbreviateNumberWithColor( + findLastNonNull(tickerFlow, "net_call_premium"), + false, + true, + )} +
+
+ +
+
+ Net Put Prem + +
+
+ {@html abbreviateNumberWithColor( + findLastNonNull(tickerFlow, "net_put_premium"), + false, + true, + )} +
+
+
+ +
+
+ {#if isLoading} +
+
+ +
+
+ {:else} + + {/if} +
+
+ {/if} +
+
+
+
+
+
+ + diff --git a/src/routes/stocks/[tickerID]/forecast/+layout.svelte b/src/routes/stocks/[tickerID]/forecast/+layout.svelte index f2390299..3323108a 100644 --- a/src/routes/stocks/[tickerID]/forecast/+layout.svelte +++ b/src/routes/stocks/[tickerID]/forecast/+layout.svelte @@ -33,10 +33,8 @@ if (state !== "overview" && subSectionMap[state]) { displaySubSection = state; - //goto(`/stocks/${$stockTicker}${subSectionMap[state]}`); } else { displaySubSection = state; - //goto(`/stocks/${$stockTicker}/stats`); } } @@ -82,6 +80,17 @@ > Analysts Ratings + diff --git a/src/routes/stocks/[tickerID]/options/+page.server.ts b/src/routes/stocks/[tickerID]/options/+page.server.ts index 59788669..f1deb841 100644 --- a/src/routes/stocks/[tickerID]/options/+page.server.ts +++ b/src/routes/stocks/[tickerID]/options/+page.server.ts @@ -26,6 +26,26 @@ export const load = async ({ locals, params }) => { }; + const getTickerFlow = async () => { + const postData = { + ticker: params.tickerID, + }; + + const response = await fetch(apiURL + "/ticker-flow", { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-API-KEY": apiKey, + }, + body: JSON.stringify(postData), + }); + + const output = await response.json(); + + return output; + }; + + const getOptionsHistoricalData = async () => { const postData = { @@ -52,6 +72,7 @@ export const load = async ({ locals, params }) => { // Make sure to return a promise return { getDailyStats: await getDailyStats(), + getTickerFlow: await getTickerFlow(), getOptionsHistoricalData: await getOptionsHistoricalData(), }; }; diff --git a/src/routes/stocks/[tickerID]/options/+page.svelte b/src/routes/stocks/[tickerID]/options/+page.svelte index 32212521..8dd132d9 100644 --- a/src/routes/stocks/[tickerID]/options/+page.svelte +++ b/src/routes/stocks/[tickerID]/options/+page.svelte @@ -1,6 +1,8 @@