This commit is contained in:
MuslemRahimi 2025-03-11 17:06:49 +01:00
parent 2587e894a6
commit e7b09f0407
6 changed files with 77 additions and 132 deletions

View File

@ -1,9 +1,10 @@
<script lang="ts">
import { abbreviateNumberWithColor, abbreviateNumber } from "$lib/utils";
import { abbreviateNumber } from "$lib/utils";
import { onMount } from "svelte";
import TableHeader from "$lib/components/Table/TableHeader.svelte";
import UpgradeToPro from "$lib/components/UpgradeToPro.svelte";
import highcharts from "$lib/highcharts.ts";
import { mode } from "mode-watcher";
export let data;
@ -44,7 +45,7 @@
const options = {
chart: {
backgroundColor: "#09090B",
backgroundColor: $mode === "light" ? "#fff" : "#09090B",
animation: false,
height: 360,
},
@ -53,19 +54,19 @@
title: {
text: `<h3 class="mt-3 mb-1 text-[1rem] sm:text-lg">Open Interest By Expiry</h3>`,
useHTML: true,
style: { color: "white" },
style: { color: $mode === "light" ? "black" : "white" },
},
xAxis: {
type: "category",
categories: categories,
crosshair: {
color: "#fff",
color: $mode === "light" ? "black" : "white",
width: 1,
dashStyle: "Solid",
},
labels: {
style: {
color: "#fff",
color: $mode === "light" ? "black" : "white",
},
distance: 10, // Adjust space between labels and axis
formatter: function () {
@ -93,9 +94,9 @@
yAxis: {
gridLineWidth: 1,
gridLineColor: "#111827",
gridLineColor: $mode === "light" ? "#d1d5dc" : "#111827",
labels: {
style: { color: "white" },
style: { color: $mode === "light" ? "black" : "white" },
},
title: { text: null },
opposite: true,
@ -113,8 +114,8 @@
},
borderRadius: 4,
formatter: function () {
// Format the x value to display time in hh:mm format
let tooltipContent = `<span class="text-white m-auto text-black text-[1rem] font-[501]">${new Date(
// Format the x value to display time in a custom format
let tooltipContent = `<span class="m-auto text-[1rem] font-[501]">${new Date(
this?.x,
).toLocaleDateString("en-US", {
year: "numeric",
@ -124,10 +125,10 @@
// Loop through each point in the shared tooltip
this.points.forEach((point) => {
tooltipContent += `<span class="text-white font-semibold text-sm">${point.series.name}:</span>
<span class="text-white font-normal text-sm" style="color:${point.color}">${abbreviateNumber(
point.y,
)}</span><br>`;
tooltipContent += `
<span style="display:inline-block; width:10px; height:10px; background-color:${point.color}; border-radius:50%; margin-right:5px;"></span>
<span class="font-semibold text-sm">${point.series.name}:</span>
<span class="font-normal text-sm">${abbreviateNumber(point.y)}</span><br>`;
});
return tooltipContent;
@ -272,28 +273,24 @@
</script>
<div class="sm:pl-7 sm:pb-7 sm:pt-7 w-full m-auto mt-2 sm:mt-0">
<h2
class=" flex flex-row items-center text-white text-xl sm:text-2xl font-bold w-fit"
>
<h2 class=" flex flex-row items-center text-xl sm:text-2xl font-bold w-fit">
Open Interest Chart
</h2>
<div class="w-full overflow-hidden m-auto mt-3">
{#if config !== null}
<div
class="border border-gray-800 rounded w-full"
class="border border-gray-300 dark:border-gray-800 rounded w-full"
use:highcharts={config}
></div>
{/if}
</div>
<h3 class="mt-5 text-xl sm:text-2xl text-white font-bold mb-3">
Open Interest Table
</h3>
<h3 class="mt-5 text-xl sm:text-2xl font-bold mb-3">Open Interest Table</h3>
<div class="w-full overflow-x-auto text-white">
<div class="w-full overflow-x-auto">
<table
class="w-full table table-sm table-compact bg-table border border-gray-800 rounded-none sm:rounded-md m-auto overflow-x-auto"
class="table table-sm table-compact no-scrollbar rounded-none sm:rounded-md w-full bg-white dark:bg-table border border-gray-300 dark:border-gray-800 m-auto"
>
<thead>
<TableHeader {columns} {sortOrders} {sortData} />
@ -301,50 +298,36 @@
<tbody>
{#each data?.user?.tier === "Pro" ? displayList : displayList?.slice(0, 3) as item, index}
<tr
class="dark:sm:hover:bg-[#245073]/10 odd:bg-[#F6F7F8] dark:odd:bg-oddborder-b border-gray-800 {index +
class="dark:sm:hover:bg-[#245073]/10 odd:bg-[#F6F7F8] dark:odd:bg-odd {index +
1 ===
displayList?.slice(0, 3)?.length &&
!['Pro']?.includes(data?.user?.tier)
? 'opacity-[0.1]'
: ''}"
>
<td
class="text-white text-sm sm:text-[1rem] text-start whitespace-nowrap"
>
<td class="text-sm sm:text-[1rem] text-start whitespace-nowrap">
{new Date(item?.expiry).toLocaleDateString("en-US", {
month: "short", // Abbreviated month (e.g., Jan)
day: "numeric", // Numeric day (e.g., 10)
year: "numeric", // Full year (e.g., 2025)
})}
</td>
<td
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap"
>
{@html abbreviateNumberWithColor(
item?.call_oi?.toFixed(2),
false,
true,
)}
<td class="text-sm sm:text-[1rem] text-end whitespace-nowrap">
{abbreviateNumber(item?.call_oi?.toFixed(2))}
</td>
<td
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap"
>
{@html abbreviateNumberWithColor(
item?.put_oi?.toFixed(2),
false,
true,
)}
<td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
{abbreviateNumber(item?.put_oi?.toFixed(2))}
</td>
<td
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap"
>
<td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
{#if item?.put_call_ratio <= 1 && item?.put_call_ratio !== null}
<span class="text-green-600 dark:text-[#00FC50]"
<span
class="font-semibold dark:font-normal text-green-600 dark:text-[#00FC50]"
>{item?.put_call_ratio?.toFixed(2)}</span
>
{:else if item?.put_call_ratio > 1 && item?.put_call_ratio !== null}
<span class="text-red-600 dark:text-[#FF2F1F]"
<span
class="font-semibold dark:font-normal text-red-600 dark:text-[#FF2F1F]"
>{item?.put_call_ratio?.toFixed(2)}</span
>
{:else}

View File

@ -1,9 +1,10 @@
<script lang="ts">
import { abbreviateNumberWithColor, abbreviateNumber } from "$lib/utils";
import { abbreviateNumber } from "$lib/utils";
import { onMount } from "svelte";
import TableHeader from "$lib/components/Table/TableHeader.svelte";
import UpgradeToPro from "$lib/components/UpgradeToPro.svelte";
import highcharts from "$lib/highcharts.ts";
import { mode } from "mode-watcher";
export let data;
@ -42,7 +43,7 @@
const options = {
chart: {
backgroundColor: "#09090B",
backgroundColor: $mode === "light" ? "#fff" : "#09090B",
animation: false,
height: 360,
},
@ -51,20 +52,20 @@
title: {
text: `<h3 class="mt-3 mb-1 text-[1rem] sm:text-lg">Open Interest By Strike</h3>`,
useHTML: true,
style: { color: "white" },
style: { color: $mode === "light" ? "black" : "white" },
},
xAxis: {
categories: strikes,
lineColor: "#fff",
lineColor: $mode === "light" ? "black" : "white",
endOnTick: false,
crosshair: {
color: "#fff", // Set the color of the crosshair line
color: $mode === "light" ? "black" : "white", // Set the color of the crosshair line
width: 1, // Adjust the line width as needed
dashStyle: "Solid",
},
labels: {
style: {
color: "#fff",
color: $mode === "light" ? "black" : "white",
},
rotation: -45,
// Only display every 5th label
@ -75,9 +76,9 @@
},
yAxis: {
gridLineWidth: 1,
gridLineColor: "#111827",
gridLineColor: $mode === "light" ? "#d1d5dc" : "#111827",
labels: {
style: { color: "white" },
style: { color: $mode === "light" ? "black" : "white" },
},
title: { text: null },
opposite: true,
@ -95,15 +96,15 @@
},
borderRadius: 4,
formatter: function () {
// Format the x value to display time in hh:mm format
// Displaying "Strike" and the x value in the header
let tooltipContent = `<span class="text-white m-auto text-black text-[1rem] font-[501]">Strike ${this?.x}</span><br>`;
// Loop through each point in the shared tooltip
this.points.forEach((point) => {
tooltipContent += `<span class="text-white font-semibold text-sm">${point.series.name}:</span>
<span class="text-white font-normal text-sm" style="color:${point.color}">${abbreviateNumber(
point.y,
)}</span><br>`;
tooltipContent += `
<span style="display:inline-block; width:10px; height:10px; background-color:${point.color}; border-radius:50%; margin-right:5px;"></span>
<span class="text-white font-semibold text-sm">${point.series.name}:</span>
<span class="text-white font-normal text-sm">${abbreviateNumber(point.y)}</span><br>`;
});
return tooltipContent;
@ -241,32 +242,33 @@
displayList = [...originalData].sort(compareValues);
};
let config = plotData() || null;
let config = null;
$: {
if ($mode) {
config = plotData() || null;
}
}
</script>
<div class="sm:pl-7 sm:pb-7 sm:pt-7 w-full m-auto mt-2 sm:mt-0">
<h2
class=" flex flex-row items-center text-white text-xl sm:text-2xl font-bold w-fit"
>
<h2 class=" flex flex-row items-center text-xl sm:text-2xl font-bold w-fit">
Open Interest Chart
</h2>
<div class="w-full overflow-hidden m-auto mt-3">
{#if config !== null}
<div
class="border border-gray-800 rounded w-full"
class="border border-gray-300 dark:border-gray-800 rounded w-full"
use:highcharts={config}
></div>
{/if}
</div>
<h3 class="mt-5 text-xl sm:text-2xl text-white font-bold mb-3">
Open Interest Table
</h3>
<h3 class="mt-5 text-xl sm:text-2xl font-bold mb-3">Open Interest Table</h3>
<div class="w-full overflow-x-auto text-white">
<div class="w-full overflow-x-auto">
<table
class="w-full table table-sm table-compact bg-table border border-gray-800 rounded-none sm:rounded-md m-auto overflow-x-auto"
class="table table-sm table-compact no-scrollbar rounded-none sm:rounded-md w-full bg-white dark:bg-table border border-gray-300 dark:border-gray-800 m-auto"
>
<thead>
<TableHeader {columns} {sortOrders} {sortData} />
@ -274,46 +276,32 @@
<tbody>
{#each data?.user?.tier === "Pro" ? displayList : displayList?.slice(0, 3) as item, index}
<tr
class="dark:sm:hover:bg-[#245073]/10 odd:bg-[#F6F7F8] dark:odd:bg-oddborder-b border-gray-800 {index +
class="dark:sm:hover:bg-[#245073]/10 odd:bg-[#F6F7F8] dark:odd:bg-odd {index +
1 ===
displayList?.slice(0, 3)?.length &&
!['Pro']?.includes(data?.user?.tier)
? 'opacity-[0.1]'
: ''}"
>
<td
class="text-white text-sm sm:text-[1rem] text-start whitespace-nowrap"
>
<td class=" text-sm sm:text-[1rem] text-start whitespace-nowrap">
{item?.strike?.toFixed(2)}
</td>
<td
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap"
>
{@html abbreviateNumberWithColor(
item?.call_oi?.toFixed(2),
false,
true,
)}
<td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
{abbreviateNumber(item?.call_oi?.toFixed(2))}
</td>
<td
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap"
>
{@html abbreviateNumberWithColor(
item?.put_oi?.toFixed(2),
false,
true,
)}
<td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
{abbreviateNumber(item?.put_oi?.toFixed(2))}
</td>
<td
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap"
>
<td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
{#if item?.put_call_ratio <= 1 && item?.put_call_ratio !== null}
<span class="text-green-600 dark:text-[#00FC50]"
<span
class="font-semibold dark:font-normal text-green-600 dark:text-[#00FC50]"
>{item?.put_call_ratio?.toFixed(2)}</span
>
{:else if item?.put_call_ratio > 1 && item?.put_call_ratio !== null}
<span class="text-red-600 dark:text-[#FF2F1F]"
<span
class="font-semibold dark:font-normal text-red-600 dark:text-[#FF2F1F]"
>{item?.put_call_ratio?.toFixed(2)}</span
>
{:else}
@ -328,21 +316,3 @@
<UpgradeToPro {data} display={true} />
</div>
<style>
.app {
height: 400px;
width: 100%;
}
@media (max-width: 560px) {
.app {
width: 100%;
height: 300px;
}
}
.chart {
width: 100%;
}
</style>

View File

@ -375,7 +375,7 @@
href={item?.analystId !== null
? `/analysts/${item?.analystId}`
: "#"}
class="text-blue-500 sm:hover:text-muted dark:sm:hover: dark:text-blue-400"
class="font-semibold dark:font-normal text-blue-500 sm:hover:text-muted dark:sm:hover: dark:text-blue-400"
>{item?.analyst_name}
</a>
@ -494,7 +494,7 @@
class=" text-end text-sm sm:text-[1rem] whitespace-nowrap"
>
<div class="flex flex-col items-end">
{#if !latestInfoDate(item?.date)}
{#if latestInfoDate(item?.date)}
<label
class="border-gray-300 shadow-sm bg-blue-100 dark:bg-[#fff] text-black font-semibold text-xs rounded px-2 py-0.5 ml-3 mb-1"
>

View File

@ -49,15 +49,15 @@
>
<main class="w-full">
<nav
class="sm:ml-4 overflow-x-auto pt-1 text-sm sm:text-[1rem] whitespace-nowrap"
class="mb-5 sm:mb-0 sm:ml-4 pt-1 text-sm sm:text-[1rem] whitespace-nowrap overflow-x-auto whitespace-nowrap"
>
<ul class="flex flex-row items-center w-full text-white">
<ul class="flex flex-row items-center w-full">
<a
href={`/stocks/${$stockTicker}/options/oi`}
on:click={() => changeSubSection("strike")}
class="p-2 px-5 cursor-pointer {displaySubSection === 'strike'
? 'text-white bg-primary/90'
: 'text-gray-400 sm:hover:text-white sm:hover:bg-primary/90'}"
? 'text-muted dark:text-white bg-[#EEEEEE] dark:bg-primary/90 font-semibold'
: 'text-blue-500 dark:text-gray-400 sm:hover:text-muted dark:sm:hover:text-white sm:hover:bg-[#EEEEEE] dark:sm:hover:bg-primary/90'}"
>
By Strike
</a>
@ -66,8 +66,8 @@
href={`/stocks/${$stockTicker}/options/oi/expiry`}
on:click={() => changeSubSection("expiry")}
class="p-2 px-5 cursor-pointer {displaySubSection === 'expiry'
? 'text-white bg-primary/90'
: 'text-gray-400 sm:hover:text-white sm:hover:bg-primary/90'}"
? 'text-muted dark:text-white bg-[#EEEEEE] dark:bg-primary/90 font-semibold'
: 'text-blue-500 dark:text-gray-400 sm:hover:text-muted dark:sm:hover:text-white sm:hover:bg-[#EEEEEE] dark:sm:hover:bg-primary/90'}"
>
By Expiry
</a>

View File

@ -1,9 +1,5 @@
<script lang="ts">
import {
stockTicker,
numberOfUnreadNotification,
displayCompanyName,
} from "$lib/store";
import { stockTicker, displayCompanyName } from "$lib/store";
import Infobox from "$lib/components/Infobox.svelte";
import SEO from "$lib/components/SEO.svelte";
@ -18,9 +14,7 @@
description={`Discover detailed Open Interest analysis by strike price for ${$displayCompanyName} (${$stockTicker}). Explore historical volume, open interest, and save individual options contracts for in-depth insights.`}
/>
<section
class="w-full bg-default overflow-hidden text-white min-h-screen pb-40"
>
<section class="w-full overflow-hidden min-h-screen pb-40">
<div class="w-full flex h-full overflow-hidden">
<div
class="w-full relative flex justify-center items-center overflow-hidden"

View File

@ -18,9 +18,7 @@
description={`Analyze Gamma Exposure by expiry for ${$displayCompanyName} (${$stockTicker}). Access historical volume, open interest trends, and save options contracts for detailed analysis and insights.`}
/>
<section
class="w-full bg-default overflow-hidden text-white min-h-screen pb-40"
>
<section class="w-full overflow-hidden min-h-screen pb-40">
<div class="w-full flex h-full overflow-hidden">
<div
class="w-full relative flex justify-center items-center overflow-hidden"