From 0cb36513097278cf34817898b11a11dccdfff3f2 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Fri, 13 Sep 2024 13:14:12 +0200 Subject: [PATCH] ui fixes --- src/routes/options-flow/+page.svelte | 185 +++++++++++++++------------ 1 file changed, 100 insertions(+), 85 deletions(-) diff --git a/src/routes/options-flow/+page.svelte b/src/routes/options-flow/+page.svelte index d6031c69..4e13dc77 100644 --- a/src/routes/options-flow/+page.svelte +++ b/src/routes/options-flow/+page.svelte @@ -373,10 +373,14 @@ function handleViewData(optionData) { previousCallVolume = displayCallVolume ?? 0; if(mode === true) { try { - const newData = JSON.parse(event.data); + let newData = JSON.parse(event.data); if(rawData?.length !== newData?.length) { newIncomingData = true; } + newData = newData?.forEach((item) => { + item.dte = daysLeft(item?.date_expiration); + }); + rawData = [...newData]; if(ruleOfList?.length !== 0 || filterQuery?.length !== 0) { @@ -404,11 +408,25 @@ function handleViewData(optionData) { } } + +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; +} onMount(async () => { audio = new Audio(notifySound); rawData = data?.getOptionsFlowFeed; + rawData?.forEach((item) => { + item.dte = daysLeft(item?.date_expiration); + }); displayedData = rawData; calculateStats(rawData); @@ -1049,17 +1067,18 @@ $: {
{#if displayedData?.length !== 0} -
+
-
- -
-
Time
+
+ +
+ +
Time
Symbol
Expiry
Strike
@@ -1071,72 +1090,68 @@ $: {
Type
Vol
OI
-
- -
handleViewData(displayedData[index])} slot="item" let:index let:style {style} class="tr cursor-pointer"> - - -
- {formatTime(displayedData[index]?.time)} -
- -
assetSelector(displayedData[index]?.ticker, displayedData[index]?.underlying_type)} style="justify-content: center;" class="td text-sm sm:hover:text-white sm:text-[1rem] text-blue-400 font-normal"> - {displayedData[index]?.ticker}
-
- {reformatDate(displayedData[index]?.date_expiration)} +
handleViewData(displayedData[index])} + slot="item" + let:index + let:style + {style} + class="tr cursor-pointer {index % 2 === 0 ? 'bg-[#27272A]' : 'bg-[#09090B]'}" + > + +
+ {formatTime(displayedData[index]?.time)} +
+ +
assetSelector(displayedData[index]?.ticker, displayedData[index]?.underlying_type)} style="justify-content: center;" class="td text-sm sm:hover:text-white sm:text-[1rem] text-blue-400 font-normal"> + {displayedData[index]?.ticker} +
+ +
+ {displayedData[index]?.dte < 0 ? 'expired' : displayedData[index]?.dte + 'd'} +
+ +
+ {displayedData[index]?.strike_price} +
+ +
+ {displayedData[index]?.put_call} +
+ +
+ {displayedData[index]?.sentiment} +
+ +
+ {displayedData[index]?.underlying_price} +
+ +
+ {displayedData[index]?.price} +
+ +
+ {abbreviateNumber(displayedData[index]?.cost_basis)} +
+ +
+ {displayedData[index]?.option_activity_type} +
+ +
+ {new Intl.NumberFormat('en', { minimumFractionDigits: 0, maximumFractionDigits: 0 }).format(displayedData[index]?.volume)} +
+ +
+ {new Intl.NumberFormat('en', { minimumFractionDigits: 0, maximumFractionDigits: 0 }).format(displayedData[index]?.open_interest)} +
- -
- {displayedData[index]?.strike_price} -
- -
- {displayedData[index]?.put_call} -
- -
- {displayedData[index]?.sentiment} -
- -
- {displayedData[index]?.underlying_price} -
- -
- {displayedData[index]?.price} -
- -
- {abbreviateNumber(displayedData[index]?.cost_basis)} -
- -
- {displayedData[index]?.option_activity_type} -
- -
- {new Intl.NumberFormat("en", { - minimumFractionDigits: 0, - maximumFractionDigits: 0 - }).format(displayedData[index]?.volume)} -
- -
- {new Intl.NumberFormat("en", { - minimumFractionDigits: 0, - maximumFractionDigits: 0 - }).format(displayedData[index]?.open_interest)} -
- -
- + +
-
- - -
{:else}
@@ -1427,16 +1442,16 @@ $: { } .table :global(.virtual-list-inner) { - width: 100%; - display: flex; - flex-direction: column; - } + width: 100%; + display: flex; + flex-direction: column; + } - @media (max-width: 768px) { - .table { - width: 1000px; - } - } + @media (max-width: 768px) { + .table { + width: 1000px; + } + } .table .virtual-list-inner { flex-flow: column nowrap; @@ -1462,11 +1477,11 @@ $: { flex-flow: row nowrap; } - .tr:nth-of-type(even) { + .tr.even { background-color: #27272A; } - .tr:nth-of-type(odd) { + .tr.odd { background-color: #09090B; } @@ -1483,4 +1498,4 @@ $: { white-space: nowrap; border-bottom: 1px solid #09090B; } - + \ No newline at end of file