ui fixes
This commit is contained in:
parent
137fcfb480
commit
0cb3651309
@ -373,10 +373,14 @@ function handleViewData(optionData) {
|
|||||||
previousCallVolume = displayCallVolume ?? 0;
|
previousCallVolume = displayCallVolume ?? 0;
|
||||||
if(mode === true) {
|
if(mode === true) {
|
||||||
try {
|
try {
|
||||||
const newData = JSON.parse(event.data);
|
let newData = JSON.parse(event.data);
|
||||||
if(rawData?.length !== newData?.length) {
|
if(rawData?.length !== newData?.length) {
|
||||||
newIncomingData = true;
|
newIncomingData = true;
|
||||||
}
|
}
|
||||||
|
newData = newData?.forEach((item) => {
|
||||||
|
item.dte = daysLeft(item?.date_expiration);
|
||||||
|
});
|
||||||
|
|
||||||
rawData = [...newData];
|
rawData = [...newData];
|
||||||
|
|
||||||
if(ruleOfList?.length !== 0 || filterQuery?.length !== 0) {
|
if(ruleOfList?.length !== 0 || filterQuery?.length !== 0) {
|
||||||
@ -405,10 +409,24 @@ 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 () => {
|
onMount(async () => {
|
||||||
audio = new Audio(notifySound);
|
audio = new Audio(notifySound);
|
||||||
rawData = data?.getOptionsFlowFeed;
|
rawData = data?.getOptionsFlowFeed;
|
||||||
|
rawData?.forEach((item) => {
|
||||||
|
item.dte = daysLeft(item?.date_expiration);
|
||||||
|
});
|
||||||
displayedData = rawData;
|
displayedData = rawData;
|
||||||
calculateStats(rawData);
|
calculateStats(rawData);
|
||||||
|
|
||||||
@ -1049,17 +1067,18 @@ $: {
|
|||||||
<!-- Page wrapper -->
|
<!-- Page wrapper -->
|
||||||
<div class="flex w-full m-auto h-full overflow-hidden">
|
<div class="flex w-full m-auto h-full overflow-hidden">
|
||||||
{#if displayedData?.length !== 0}
|
{#if displayedData?.length !== 0}
|
||||||
<div class="mt-8 w-full overflow-x-auto overflow-y-auto h-[850px]">
|
<div class="mt-8 w-full overflow-x-auto overflow-y-auto h-[850px]">
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
<div class="table">
|
<div class="table">
|
||||||
<VirtualList
|
<VirtualList
|
||||||
width="100%"
|
width="100%"
|
||||||
height={850}
|
height={850}
|
||||||
itemCount={displayedData.length}
|
itemCount={displayedData.length}
|
||||||
itemSize={40}
|
itemSize={40}
|
||||||
>
|
>
|
||||||
<div slot="header" class="tr th sticky z-40 top-0">
|
<div slot="header" class="tr th sticky z-40 top-0">
|
||||||
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Time</div>
|
<!-- Table headers -->
|
||||||
|
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Time</div>
|
||||||
<div class="td bg-[#161618] font-bold text-slate-300 text-xs text-start uppercase">Symbol</div>
|
<div class="td bg-[#161618] font-bold text-slate-300 text-xs text-start uppercase">Symbol</div>
|
||||||
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Expiry</div>
|
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Expiry</div>
|
||||||
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Strike</div>
|
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Strike</div>
|
||||||
@ -1071,72 +1090,68 @@ $: {
|
|||||||
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Type</div>
|
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-start uppercase">Type</div>
|
||||||
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-end uppercase">Vol</div>
|
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-end uppercase">Vol</div>
|
||||||
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-end uppercase">OI</div>
|
<div class="td bg-[#161618] text-slate-300 font-bold text-xs text-end uppercase">OI</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div on:click={() => handleViewData(displayedData[index])} slot="item" let:index let:style {style} class="tr cursor-pointer">
|
|
||||||
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-white pb-3 text-xs sm:text-sm text-start">
|
|
||||||
{formatTime(displayedData[index]?.time)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div on:click|stopPropagation={() => 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">
|
<div
|
||||||
{displayedData[index]?.ticker}
|
on:click={() => handleViewData(displayedData[index])}
|
||||||
|
slot="item"
|
||||||
|
let:index
|
||||||
|
let:style
|
||||||
|
{style}
|
||||||
|
class="tr cursor-pointer {index % 2 === 0 ? 'bg-[#27272A]' : 'bg-[#09090B]'}"
|
||||||
|
>
|
||||||
|
<!-- Row data -->
|
||||||
|
<div style="justify-content: center;" class="td text-white pb-3 text-xs sm:text-sm text-start">
|
||||||
|
{formatTime(displayedData[index]?.time)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div on:click|stopPropagation={() => 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}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-start">
|
||||||
|
{displayedData[index]?.dte < 0 ? 'expired' : displayedData[index]?.dte + 'd'}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-start">
|
||||||
|
{displayedData[index]?.strike_price}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] {displayedData[index]?.put_call === 'Calls' ? 'text-[#00FC50]' : 'text-[#FC2120]'} text-start">
|
||||||
|
{displayedData[index]?.put_call}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] {displayedData[index]?.sentiment === 'Bullish' ? 'text-[#00FC50]' : displayedData[index]?.sentiment === 'Bearish' ? 'text-[#FC2120]' : 'text-[#C6A755]'} text-start">
|
||||||
|
{displayedData[index]?.sentiment}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start text-white">
|
||||||
|
{displayedData[index]?.underlying_price}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start text-white">
|
||||||
|
{displayedData[index]?.price}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start font-semibold {displayedData[index]?.put_call === 'Puts' ? 'text-[#CB281C]' : 'text-[#0FB307]'}">
|
||||||
|
{abbreviateNumber(displayedData[index]?.cost_basis)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start {displayedData[index]?.option_activity_type === 'Sweep' ? 'text-[#C6A755]' : 'text-[#976DB7]'}">
|
||||||
|
{displayedData[index]?.option_activity_type}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-end">
|
||||||
|
{new Intl.NumberFormat('en', { minimumFractionDigits: 0, maximumFractionDigits: 0 }).format(displayedData[index]?.volume)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-end">
|
||||||
|
{new Intl.NumberFormat('en', { minimumFractionDigits: 0, maximumFractionDigits: 0 }).format(displayedData[index]?.open_interest)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</VirtualList>
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-start">
|
</div>
|
||||||
{reformatDate(displayedData[index]?.date_expiration)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-start">
|
|
||||||
{displayedData[index]?.strike_price}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] {displayedData[index]?.put_call === 'Calls' ? 'text-[#00FC50]' : 'text-[#FC2120]'} text-start">
|
|
||||||
{displayedData[index]?.put_call}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] {displayedData[index]?.sentiment === 'Bullish' ? 'text-[#00FC50]' : displayedData[index]?.sentiment === 'Bearish' ? 'text-[#FC2120]' : 'text-[#C6A755]'} text-start">
|
|
||||||
{displayedData[index]?.sentiment}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start text-white">
|
|
||||||
{displayedData[index]?.underlying_price}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start text-white">
|
|
||||||
{displayedData[index]?.price}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start font-semibold {displayedData[index]?.put_call === 'Puts' ? 'text-[#CB281C]' : 'text-[#0FB307]'} ">
|
|
||||||
{abbreviateNumber(displayedData[index]?.cost_basis)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-start {displayedData[index]?.option_activity_type === 'Sweep' ? 'text-[#C6A755]' : 'text-[#976DB7]'}">
|
|
||||||
{displayedData[index]?.option_activity_type}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-end">
|
|
||||||
{new Intl.NumberFormat("en", {
|
|
||||||
minimumFractionDigits: 0,
|
|
||||||
maximumFractionDigits: 0
|
|
||||||
}).format(displayedData[index]?.volume)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="justify-content: center;" class="td text-sm sm:text-[1rem] text-white text-end">
|
|
||||||
{new Intl.NumberFormat("en", {
|
|
||||||
minimumFractionDigits: 0,
|
|
||||||
maximumFractionDigits: 0
|
|
||||||
}).format(displayedData[index]?.open_interest)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</VirtualList>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!--<InfiniteLoading on:infinite={infiniteHandler} />-->
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="text-white text-center p-3 sm:p-5 mb-10 rounded-lg sm:flex sm:flex-row sm:items-center border border-slate-800 text-sm sm:text-[1rem]">
|
<div class="text-white text-center p-3 sm:p-5 mb-10 rounded-lg sm:flex sm:flex-row sm:items-center border border-slate-800 text-sm sm:text-[1rem]">
|
||||||
@ -1427,16 +1442,16 @@ $: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.table :global(.virtual-list-inner) {
|
.table :global(.virtual-list-inner) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.table {
|
.table {
|
||||||
width: 1000px;
|
width: 1000px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.table .virtual-list-inner {
|
.table .virtual-list-inner {
|
||||||
flex-flow: column nowrap;
|
flex-flow: column nowrap;
|
||||||
@ -1462,11 +1477,11 @@ $: {
|
|||||||
flex-flow: row nowrap;
|
flex-flow: row nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tr:nth-of-type(even) {
|
.tr.even {
|
||||||
background-color: #27272A;
|
background-color: #27272A;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tr:nth-of-type(odd) {
|
.tr.odd {
|
||||||
background-color: #09090B;
|
background-color: #09090B;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user