This commit is contained in:
MuslemRahimi 2025-03-11 16:20:27 +01:00
parent 18c46c4a28
commit 2587e894a6
3 changed files with 50 additions and 66 deletions

View File

@ -1,14 +1,11 @@
<script lang="ts"> <script lang="ts">
import { import { removeCompanyStrings, abbreviateNumber } from "$lib/utils";
removeCompanyStrings,
abbreviateNumberWithColor,
abbreviateNumber,
} from "$lib/utils";
import { displayCompanyName } from "$lib/store"; import { displayCompanyName } from "$lib/store";
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;
@ -96,7 +93,7 @@
const options = { const options = {
chart: { chart: {
backgroundColor: "#09090B", backgroundColor: $mode === "light" ? "#fff" : "#09090B",
animation: false, animation: false,
height: 360, height: 360,
}, },
@ -105,7 +102,7 @@
title: { title: {
text: `<h3 class="mt-3 mb-1 text-[1rem] sm:text-lg">Volatiltiy Exposure</h3>`, text: `<h3 class="mt-3 mb-1 text-[1rem] sm:text-lg">Volatiltiy Exposure</h3>`,
useHTML: true, useHTML: true,
style: { color: "white" }, style: { color: $mode === "light" ? "black" : "white" },
}, },
// Disable markers globally on hover for all series // Disable markers globally on hover for all series
xAxis: { xAxis: {
@ -113,13 +110,13 @@
endOnTick: false, endOnTick: false,
categories: dateList, categories: dateList,
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",
}, },
distance: 20, // Increases space between label and axis distance: 20, // Increases space between label and axis
formatter: function () { formatter: function () {
@ -146,9 +143,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,
@ -179,8 +176,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",
@ -190,10 +187,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;
@ -210,7 +207,7 @@
}, },
}, },
}, },
color: "white", color: $mode === "light" ? "black" : "white",
animation: false, // Disable series animation animation: false, // Disable series animation
states: { states: {
hover: { hover: {
@ -226,7 +223,7 @@
data: priceList, data: priceList,
yAxis: 1, yAxis: 1,
lineWidth: 2, lineWidth: 2,
color: "#fff", color: $mode === "light" ? "black" : "white",
animation: false, animation: false,
}, },
{ {
@ -235,7 +232,7 @@
data: impliedVolatility, data: impliedVolatility,
lineWidth: 2, lineWidth: 2,
yAxis: 0, yAxis: 0,
color: "#FAD776", color: $mode === "light" ? "#C69307" : "#FAD776",
animation: false, animation: false,
}, },
{ {
@ -404,16 +401,14 @@
}; };
$: { $: {
if (timePeriod) { if (timePeriod || $mode) {
config = plotData(); config = plotData();
} }
} }
</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"
>
Volatility Exposure Volatility Exposure
</h2> </h2>
<div class="w-full mt-2"> <div class="w-full mt-2">
@ -430,19 +425,20 @@
{#if data?.user?.tier === "Pro" || index === 0} {#if data?.user?.tier === "Pro" || index === 0}
<label <label
on:click={() => (timePeriod = item)} on:click={() => (timePeriod = item)}
class="px-3 py-1 text-sm {timePeriod === item class="px-3 py-1 text-sm shadow-sm border-gray-300 {timePeriod ===
? 'bg-white text-black ' item
: 'text-white bg-table text-opacity-[0.6]'} transition ease-out duration-100 sm:hover:bg-white sm:hover:text-black rounded-md cursor-pointer" ? 'bg-gray-300 dark:bg-white text-black '
: ' bg-gray-100 dark:bg-table text-opacity-[0.6]'} transition ease-out duration-100 rounded-md cursor-pointer"
> >
{item} {item}
</label> </label>
{:else if data?.user?.tier !== "Pro"} {:else if data?.user?.tier !== "Pro"}
<a <a
href="/pricing" href="/pricing"
class="px-3 py-1 text-sm flex flex-row items-center border border-gray-700 {timePeriod === class="px-3 py-1 text-sm flex flex-row items-center border border-gray-300 {timePeriod ===
item item
? 'bg-white text-black ' ? 'bg-gray-300 dark:bg-white text-black '
: 'text-white bg-table text-opacity-[0.6]'} transition ease-out duration-100 sm:hover:bg-white sm:hover:text-black rounded-md cursor-pointer" : ' bg-gray-100 dark:bg-table text-opacity-[0.6]'} transition ease-out duration-100 rounded-md cursor-pointer"
> >
{item} {item}
<svg <svg
@ -460,18 +456,18 @@
</div> </div>
<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-2 sm:mb-0"> <h3 class="mt-5 text-xl sm:text-2xl font-bold mb-2 sm:mb-0">
Volatility History Volatility History
</h3> </h3>
<div class="w-full overflow-x-auto text-white mt-5"> <div class="w-full overflow-x-auto mt-5">
<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 mt-4"
> >
<thead> <thead>
<TableHeader {columns} {sortOrders} {sortData} /> <TableHeader {columns} {sortOrders} {sortData} />
@ -479,30 +475,28 @@
<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"
>
{formatDate(item?.date)} {formatDate(item?.date)}
</td> </td>
<td class="text-white text-sm sm:text-[1rem] text-end"> <td class=" text-sm sm:text-[1rem] text-end">
{#if item?.changesPercentage >= 0 && item?.changesPercentage !== null} {#if item?.changesPercentage >= 0 && item?.changesPercentage !== null}
<span class="text-green-600 dark:text-[#00FC50]" <span class="text-green-600 dark:text-[#00FC50]"
>+{item?.changesPercentage >= 1000 >+{item?.changesPercentage >= 1000
? abbreviateNumberWithColor(item?.changesPercentage) ? abbreviateNumber(item?.changesPercentage)
: item?.changesPercentage?.toFixed(2)}%</span : item?.changesPercentage?.toFixed(2)}%</span
> >
{:else if item?.changesPercentage < 0 && item?.changesPercentage !== null} {:else if item?.changesPercentage < 0 && item?.changesPercentage !== null}
<span class="text-red-600 dark:text-[#FF2F1F]" <span class="text-red-600 dark:text-[#FF2F1F]"
>{item?.changesPercentage <= -1000 >{item?.changesPercentage <= -1000
? abbreviateNumberWithColor(item?.changesPercentage) ? abbreviateNumber(item?.changesPercentage)
: item?.changesPercentage?.toFixed(2)}% : item?.changesPercentage?.toFixed(2)}%
</span> </span>
{:else} {:else}
@ -510,50 +504,40 @@
{/if} {/if}
</td> </td>
<td class="text-sm sm:text-[1rem] text-end text-white"> <td class="text-sm sm:text-[1rem] text-end">
{item?.putCallRatio} {item?.putCallRatio}
</td> </td>
<td class="text-sm sm:text-[1rem] text-end text-white"> <td class="text-sm sm:text-[1rem] text-end">
{@html abbreviateNumberWithColor( {@html abbreviateNumber(item?.total_open_interest, false, true)}
item?.total_open_interest,
false,
true,
)}
</td> </td>
<td class="text-white text-sm sm:text-[1rem] text-end"> <td class=" text-sm sm:text-[1rem] text-end">
{#if item?.changesPercentageOI >= 0 && item?.changesPercentageOI !== null} {#if item?.changesPercentageOI >= 0 && item?.changesPercentageOI !== null}
<span class="text-green-600 dark:text-[#00FC50]" <span class="text-green-600 dark:text-[#00FC50]"
>+{item?.changesPercentageOI >= 1000 >+{item?.changesPercentageOI >= 1000
? abbreviateNumberWithColor(item?.changesPercentageOI) ? abbreviateNumber(item?.changesPercentageOI)
: item?.changesPercentageOI?.toFixed(2)}%</span : item?.changesPercentageOI?.toFixed(2)}%</span
> >
{:else if item?.changesPercentageOI < 0 && item?.changesPercentageOI !== null} {:else if item?.changesPercentageOI < 0 && item?.changesPercentageOI !== null}
<span class="text-red-600 dark:text-[#FF2F1F]" <span class="text-red-600 dark:text-[#FF2F1F]"
>{item?.changesPercentageOI <= -1000 >{item?.changesPercentageOI <= -1000
? abbreviateNumberWithColor(item?.changesPercentageOI) ? abbreviateNumber(item?.changesPercentageOI)
: item?.changesPercentageOI?.toFixed(2)}% : item?.changesPercentageOI?.toFixed(2)}%
</span> </span>
{:else} {:else}
<span class="text-white"> n/a </span> <span class=""> n/a </span>
{/if} {/if}
</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"
>
{item?.iv} {item?.iv}
</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"
>
{item?.rv ?? "n/a"} {item?.rv ?? "n/a"}
</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"
>
{item?.volatilitySpread ?? "n/a"} {item?.volatilitySpread ?? "n/a"}
</td> </td>
</tr> </tr>

View File

@ -96,7 +96,7 @@
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
<div <div
class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed
? 'bg-[#F9AB00]/10' ? 'bg-blue-100 dark:bg-[#F9AB00]/10'
: ''} " : ''} "
> >
<div class="flex flex-row items-center w-full"> <div class="flex flex-row items-center w-full">
@ -146,7 +146,7 @@
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
<div <div
class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed
? 'bg-[#F9AB00]/10' ? 'bg-blue-100 dark:bg-[#F9AB00]/10'
: ''} " : ''} "
> >
<div class="flex flex-row items-center w-full"> <div class="flex flex-row items-center w-full">
@ -192,7 +192,7 @@
{:else if item?.notifyType === "topAnalyst"} {:else if item?.notifyType === "topAnalyst"}
<div <div
class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed
? 'bg-[#F9AB00]/10' ? 'bg-blue-100 dark:bg-[#F9AB00]/10'
: ''} " : ''} "
> >
<div class="flex flex-row items-center w-full"> <div class="flex flex-row items-center w-full">
@ -243,7 +243,7 @@
{:else if item?.notifyType === "earningsSurprise"} {:else if item?.notifyType === "earningsSurprise"}
<div <div
class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed class="border-b border-gray-300 dark:border-gray-800 pb-3 sm:p-3 mb-6 sm:mb-3 w-full {!item?.readed
? 'bg-[#F9AB00]/10' ? 'bg-blue-100 dark:bg-[#F9AB00]/10'
: ''} " : ''} "
> >
<div class="flex flex-row items-center w-full"> <div class="flex flex-row items-center w-full">

View File

@ -14,7 +14,7 @@
description={`Track volatility and implied volatility trends with our interactive chart. Analyze price movements, 30-day implied volatility, and realized volatility to make data-driven trading decisions.`} description={`Track volatility and implied volatility trends with our interactive chart. Analyze price movements, 30-day implied volatility, and realized volatility to make data-driven trading decisions.`}
/> />
<section class="w-full bg-default overflow-hidden text-white min-h-screen"> <section class="w-full overflow-hidden min-h-screen">
<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"