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

View File

@ -1,9 +1,10 @@
<script lang="ts"> <script lang="ts">
import { abbreviateNumberWithColor, abbreviateNumber } from "$lib/utils"; import { abbreviateNumber } from "$lib/utils";
import { onMount } from "svelte"; import { onMount } from "svelte";
import TableHeader from "$lib/components/Table/TableHeader.svelte"; import TableHeader from "$lib/components/Table/TableHeader.svelte";
import UpgradeToPro from "$lib/components/UpgradeToPro.svelte"; import UpgradeToPro from "$lib/components/UpgradeToPro.svelte";
import highcharts from "$lib/highcharts.ts"; import highcharts from "$lib/highcharts.ts";
import { mode } from "mode-watcher";
export let data; export let data;
@ -42,7 +43,7 @@
const options = { const options = {
chart: { chart: {
backgroundColor: "#09090B", backgroundColor: $mode === "light" ? "#fff" : "#09090B",
animation: false, animation: false,
height: 360, height: 360,
}, },
@ -51,20 +52,20 @@
title: { title: {
text: `<h3 class="mt-3 mb-1 text-[1rem] sm:text-lg">Open Interest By Strike</h3>`, text: `<h3 class="mt-3 mb-1 text-[1rem] sm:text-lg">Open Interest By Strike</h3>`,
useHTML: true, useHTML: true,
style: { color: "white" }, style: { color: $mode === "light" ? "black" : "white" },
}, },
xAxis: { xAxis: {
categories: strikes, categories: strikes,
lineColor: "#fff", lineColor: $mode === "light" ? "black" : "white",
endOnTick: false, endOnTick: false,
crosshair: { 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 width: 1, // Adjust the line width as needed
dashStyle: "Solid", dashStyle: "Solid",
}, },
labels: { labels: {
style: { style: {
color: "#fff", color: $mode === "light" ? "black" : "white",
}, },
rotation: -45, rotation: -45,
// Only display every 5th label // Only display every 5th label
@ -75,9 +76,9 @@
}, },
yAxis: { yAxis: {
gridLineWidth: 1, gridLineWidth: 1,
gridLineColor: "#111827", gridLineColor: $mode === "light" ? "#d1d5dc" : "#111827",
labels: { labels: {
style: { color: "white" }, style: { color: $mode === "light" ? "black" : "white" },
}, },
title: { text: null }, title: { text: null },
opposite: true, opposite: true,
@ -95,15 +96,15 @@
}, },
borderRadius: 4, borderRadius: 4,
formatter: function () { 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>`; 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 // Loop through each point in the shared tooltip
this.points.forEach((point) => { this.points.forEach((point) => {
tooltipContent += `<span class="text-white font-semibold text-sm">${point.series.name}:</span> tooltipContent += `
<span class="text-white font-normal text-sm" style="color:${point.color}">${abbreviateNumber( <span style="display:inline-block; width:10px; height:10px; background-color:${point.color}; border-radius:50%; margin-right:5px;"></span>
point.y, <span class="text-white font-semibold text-sm">${point.series.name}:</span>
)}</span><br>`; <span class="text-white font-normal text-sm">${abbreviateNumber(point.y)}</span><br>`;
}); });
return tooltipContent; return tooltipContent;
@ -241,32 +242,33 @@
displayList = [...originalData].sort(compareValues); displayList = [...originalData].sort(compareValues);
}; };
let config = plotData() || null; let config = null;
$: {
if ($mode) {
config = plotData() || null;
}
}
</script> </script>
<div class="sm:pl-7 sm:pb-7 sm:pt-7 w-full m-auto mt-2 sm:mt-0"> <div class="sm:pl-7 sm:pb-7 sm:pt-7 w-full m-auto mt-2 sm:mt-0">
<h2 <h2 class=" flex flex-row items-center text-xl sm:text-2xl font-bold w-fit">
class=" flex flex-row items-center text-white text-xl sm:text-2xl font-bold w-fit"
>
Open Interest Chart Open Interest Chart
</h2> </h2>
<div class="w-full overflow-hidden m-auto mt-3"> <div class="w-full overflow-hidden m-auto mt-3">
{#if config !== null} {#if config !== null}
<div <div
class="border border-gray-800 rounded w-full" class="border border-gray-300 dark:border-gray-800 rounded w-full"
use:highcharts={config} use:highcharts={config}
></div> ></div>
{/if} {/if}
</div> </div>
<h3 class="mt-5 text-xl sm:text-2xl text-white font-bold mb-3"> <h3 class="mt-5 text-xl sm:text-2xl font-bold mb-3">Open Interest Table</h3>
Open Interest Table
</h3>
<div class="w-full overflow-x-auto text-white"> <div class="w-full overflow-x-auto">
<table <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> <thead>
<TableHeader {columns} {sortOrders} {sortData} /> <TableHeader {columns} {sortOrders} {sortData} />
@ -274,46 +276,32 @@
<tbody> <tbody>
{#each data?.user?.tier === "Pro" ? displayList : displayList?.slice(0, 3) as item, index} {#each data?.user?.tier === "Pro" ? displayList : displayList?.slice(0, 3) as item, index}
<tr <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 === 1 ===
displayList?.slice(0, 3)?.length && displayList?.slice(0, 3)?.length &&
!['Pro']?.includes(data?.user?.tier) !['Pro']?.includes(data?.user?.tier)
? 'opacity-[0.1]' ? 'opacity-[0.1]'
: ''}" : ''}"
> >
<td <td class=" text-sm sm:text-[1rem] text-start whitespace-nowrap">
class="text-white text-sm sm:text-[1rem] text-start whitespace-nowrap"
>
{item?.strike?.toFixed(2)} {item?.strike?.toFixed(2)}
</td> </td>
<td <td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap" {abbreviateNumber(item?.call_oi?.toFixed(2))}
>
{@html abbreviateNumberWithColor(
item?.call_oi?.toFixed(2),
false,
true,
)}
</td> </td>
<td <td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap" {abbreviateNumber(item?.put_oi?.toFixed(2))}
>
{@html abbreviateNumberWithColor(
item?.put_oi?.toFixed(2),
false,
true,
)}
</td> </td>
<td <td class=" text-sm sm:text-[1rem] text-end whitespace-nowrap">
class="text-white text-sm sm:text-[1rem] text-end whitespace-nowrap"
>
{#if item?.put_call_ratio <= 1 && item?.put_call_ratio !== null} {#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 >{item?.put_call_ratio?.toFixed(2)}</span
> >
{:else if item?.put_call_ratio > 1 && item?.put_call_ratio !== null} {: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 >{item?.put_call_ratio?.toFixed(2)}</span
> >
{:else} {:else}
@ -328,21 +316,3 @@
<UpgradeToPro {data} display={true} /> <UpgradeToPro {data} display={true} />
</div> </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 href={item?.analystId !== null
? `/analysts/${item?.analystId}` ? `/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} >{item?.analyst_name}
</a> </a>
@ -494,7 +494,7 @@
class=" text-end text-sm sm:text-[1rem] whitespace-nowrap" class=" text-end text-sm sm:text-[1rem] whitespace-nowrap"
> >
<div class="flex flex-col items-end"> <div class="flex flex-col items-end">
{#if !latestInfoDate(item?.date)} {#if latestInfoDate(item?.date)}
<label <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" 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"> <main class="w-full">
<nav <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 <a
href={`/stocks/${$stockTicker}/options/oi`} href={`/stocks/${$stockTicker}/options/oi`}
on:click={() => changeSubSection("strike")} on:click={() => changeSubSection("strike")}
class="p-2 px-5 cursor-pointer {displaySubSection === 'strike' class="p-2 px-5 cursor-pointer {displaySubSection === 'strike'
? 'text-white bg-primary/90' ? 'text-muted dark:text-white bg-[#EEEEEE] dark:bg-primary/90 font-semibold'
: 'text-gray-400 sm:hover:text-white sm:hover:bg-primary/90'}" : '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 By Strike
</a> </a>
@ -66,8 +66,8 @@
href={`/stocks/${$stockTicker}/options/oi/expiry`} href={`/stocks/${$stockTicker}/options/oi/expiry`}
on:click={() => changeSubSection("expiry")} on:click={() => changeSubSection("expiry")}
class="p-2 px-5 cursor-pointer {displaySubSection === 'expiry' class="p-2 px-5 cursor-pointer {displaySubSection === 'expiry'
? 'text-white bg-primary/90' ? 'text-muted dark:text-white bg-[#EEEEEE] dark:bg-primary/90 font-semibold'
: 'text-gray-400 sm:hover:text-white sm:hover:bg-primary/90'}" : '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 By Expiry
</a> </a>

View File

@ -1,9 +1,5 @@
<script lang="ts"> <script lang="ts">
import { import { stockTicker, displayCompanyName } from "$lib/store";
stockTicker,
numberOfUnreadNotification,
displayCompanyName,
} from "$lib/store";
import Infobox from "$lib/components/Infobox.svelte"; import Infobox from "$lib/components/Infobox.svelte";
import SEO from "$lib/components/SEO.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.`} 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 <section class="w-full overflow-hidden min-h-screen pb-40">
class="w-full bg-default overflow-hidden text-white min-h-screen pb-40"
>
<div class="w-full flex h-full overflow-hidden"> <div class="w-full flex h-full overflow-hidden">
<div <div
class="w-full relative flex justify-center items-center overflow-hidden" 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.`} 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 <section class="w-full overflow-hidden min-h-screen pb-40">
class="w-full bg-default overflow-hidden text-white min-h-screen pb-40"
>
<div class="w-full flex h-full overflow-hidden"> <div class="w-full flex h-full overflow-hidden">
<div <div
class="w-full relative flex justify-center items-center overflow-hidden" class="w-full relative flex justify-center items-center overflow-hidden"