From 4b26a2ac8bad17a09dca9ca6d0fe0c2b622e54e5 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sun, 8 Sep 2024 17:38:33 +0200 Subject: [PATCH] add single transactions --- .../stocks/[tickerID]/options/+page.svelte | 246 +++++++++++++++++- 1 file changed, 243 insertions(+), 3 deletions(-) diff --git a/src/routes/stocks/[tickerID]/options/+page.svelte b/src/routes/stocks/[tickerID]/options/+page.svelte index b920de2f..e60804fb 100644 --- a/src/routes/stocks/[tickerID]/options/+page.svelte +++ b/src/routes/stocks/[tickerID]/options/+page.svelte @@ -448,6 +448,32 @@ onMount(async () => { }; } }) + + +function daysLeft(targetDate) { + const targetTime = new Date(targetDate).getTime(); + const currentTime = new Date().getTime(); + const difference = targetTime - currentTime; + + const millisecondsPerDay = 1000 * 60 * 60 * 24; + const daysLeft = Math?.ceil(difference / millisecondsPerDay); + + return daysLeft; +} + +let optionHistoryList = []; + +function handleViewData(optionData) { + + optionHistoryList = optionData; + optionHistoryList?.forEach((item) => { + item.dte = daysLeft(item?.date_expiration); + }); + //const openPopup = $screenWidth < 640 ? document.getElementById("optionDetailsMobileModal") : document.getElementById("optionDetailsDesktopModal"); + //openPopup?.dispatchEvent(new MouseEvent('click')) + + optionDetailsDesktopModal?.showModal() +} $: { @@ -496,7 +522,7 @@ $: {
-
+

Unsual Options Activity @@ -644,6 +670,7 @@ $: { % Change P/C Bear/Bull + % OTM Total Volume Total OI Total Prem @@ -651,7 +678,7 @@ $: { {#each (data?.user?.tier === 'Pro' ? optionList : optionList?.slice(0,3)) as item, index} - + handleViewData(item?.history)} class="cursor-pointer sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] {index+1 === optionList?.slice(0,3)?.length && data?.user?.tier !== 'Pro' ? 'opacity-[0.1]' : ''}"> @@ -670,7 +697,7 @@ $: { {(item?.p_vol/item?.c_vol)?.toFixed(2)} - + {#if item?.bear_ratio > (item?.neutral_ratio ?? 0) && item?.bear_ratio > (item?.bull_ratio ?? 0)}
{item?.bear_ratio?.toFixed(0)}% Bearish @@ -702,6 +729,11 @@ $: { {/if} + + {item?.otm_ratio?.toFixed(0)}% + + + {abbreviateNumber(item?.total_volume)} @@ -754,7 +786,215 @@ $: {

+ + + + + + + + + + + + + + + + + + + + +