bugfixing options flow

This commit is contained in:
MuslemRahimi 2025-02-26 21:28:56 +01:00
parent 6c47c6fbac
commit b3e96b68b2
2 changed files with 46 additions and 67 deletions

View File

@ -1,11 +1,6 @@
<script lang="ts">
import notifySound from "$lib/audio/options-flow-reader.mp3";
import {
numberOfUnreadNotification,
getCache,
setCache,
isOpen,
} from "$lib/store";
import { getCache, setCache, isOpen } from "$lib/store";
import { cn, sectorList } from "$lib/utils";
import { onMount, onDestroy } from "svelte";
@ -18,6 +13,7 @@
import UpgradeToPro from "$lib/components/UpgradeToPro.svelte";
import { page } from "$app/stores";
import SEO from "$lib/components/SEO.svelte";
import DarkPoolTable from "$lib/components/Table/DarkPoolTable.svelte";
import { writable } from "svelte/store";
@ -694,37 +690,11 @@
}
</script>
<svelte:head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0" />
<title>
{$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} Dark
Pool Flow Feed · Stocknear
</title>
<meta
name="description"
content={`Explore unusual dark pool trades from big institutional traders and hedge funds.`}
/>
<!-- Other meta tags -->
<meta property="og:title" content={`Dark Pool Flow · Stocknear`} />
<meta
property="og:description"
content={`Explore unusual dark pool trades from big institutional traders and hedge funds.`}
/>
<meta property="og:type" content="website" />
<!-- Add more Open Graph meta tags as needed -->
<!-- Twitter specific meta tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={`Dark Pool Flow · Stocknear`} />
<meta
name="twitter:description"
content={`Explore unusual dark pool trades from big institutional traders and hedge funds.`}
/>
<!-- Add more Twitter meta tags as needed -->
</svelte:head>
<SEO
title="Dark
Pool Flow Feed"
description="Explore unusual dark pool trades from big institutional traders and hedge funds."
/>
<body class="overflow-y-auto">
<section
@ -744,7 +714,7 @@
<div
class="text-white text-sm sm:text-[1rem] italic text-center sm:text-start w-full ml-2 mb-3"
>
Live flow of {data?.user?.tier === "Pro" && selectedDate
Dark Pool Live flow of {data?.user?.tier === "Pro" && selectedDate
? df.format(selectedDate?.toDate())
: nyseDate} (NYSE Time)
</div>

View File

@ -229,7 +229,8 @@
function handleAddRule() {
if (ruleName === "") {
toast.error("Please select a rule", {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
return;
}
@ -468,14 +469,9 @@
new Date().toLocaleString("en-US", { timeZone: "America/New_York" }),
)?.getTime();
const nyseDate = new Date(
data?.getOptionsFlowFeed?.at(0)?.date ?? null,
)?.toLocaleString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
timeZone: "Europe/Berlin",
});
const dateString = data?.getOptionsFlowFeed?.at(0)?.date;
const nyseDate = new Date(`${dateString}T12:00:00Z`);
const formattedNyseDate = nyseDate.toISOString().split("T")[0];
let rawData = data?.getOptionsFlowFeed?.filter((item) =>
Object?.values(item)?.every(
@ -520,7 +516,8 @@
}
} else {
toast.error(`Market is closed`, {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
}
@ -749,34 +746,46 @@
const year = convertDate?.getFullYear();
const month = String(convertDate?.getMonth() + 1).padStart(2, "0");
const day = String(convertDate?.getDate()).padStart(2, "0");
const formattedDate = `${year}-${month}-${day}`;
const postData = { selectedDate: `${year}-${month}-${day}` };
try {
const response = await fetch("/api/options-historical-flow", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(postData),
});
rawData = await response?.json();
if (formattedDate === formattedNyseDate) {
rawData = data?.getOptionsFlowFeed;
if (rawData?.length !== 0) {
rawData?.forEach((item) => {
item.dte = daysLeft(item?.date_expiration);
});
shouldLoadWorker.set(true);
}
} catch (error) {
console.error("Error fetching historical flow:", error);
rawData = [];
} finally {
isLoaded = true;
} else {
const postData = { selectedDate: formattedDate };
try {
const response = await fetch("/api/options-historical-flow", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(postData),
});
rawData = await response?.json();
if (rawData?.length !== 0) {
rawData?.forEach((item) => {
item.dte = daysLeft(item?.date_expiration);
});
shouldLoadWorker.set(true);
}
} catch (error) {
console.error("Error fetching historical flow:", error);
rawData = [];
} finally {
isLoaded = true;
}
}
} else {
toast.error("Only for Pro Members", {
style: "border-radius: 200px; background: #2A2E39; color: #fff;",
style:
"border-radius: 5px; background: #fff; color: #000; border-color: #4B5563; font-size: 15px;",
});
}
};
@ -845,7 +854,7 @@
<div
class="text-white text-sm sm:text-[1rem] italic text-center sm:text-start w-full ml-2 mb-3"
>
Live flow of {data?.user?.tier === "Pro" && selectedDate
Options Live flow of {data?.user?.tier === "Pro" && selectedDate
? df.format(selectedDate?.toDate())
: nyseDate} (NYSE Time)
</div>