refactor etf page
This commit is contained in:
parent
220f9db0ed
commit
6d6fd2d5ce
@ -280,14 +280,10 @@
|
||||
if ($page?.url?.pathname && typeof window !== "undefined") {
|
||||
const parts = $page?.url?.pathname?.split("/");
|
||||
const sectionMap = {
|
||||
statistics: "statistics",
|
||||
financials: "financials",
|
||||
holdings: "holdings",
|
||||
options: "options",
|
||||
metrics: "metrics",
|
||||
insider: "insider",
|
||||
dividends: "dividends",
|
||||
forecast: "forecast",
|
||||
news: "news",
|
||||
};
|
||||
displaySection =
|
||||
sectionMap[
|
||||
@ -688,49 +684,16 @@
|
||||
Overview
|
||||
</a>
|
||||
<a
|
||||
href={`/etf/${$etfTicker}/financials`}
|
||||
on:click={() => changeSection("financials")}
|
||||
href={`/etf/${$etfTicker}/holdings`}
|
||||
on:click={() => changeSection("holdings")}
|
||||
class="p-2 px-5 cursor-pointer {displaySection ===
|
||||
'financials'
|
||||
'holdings'
|
||||
? 'text-white bg-[#27272A] sm:hover:bg-opacity-[0.95]'
|
||||
: 'text-gray-400 sm:hover:text-white sm:hover:bg-[#27272A] sm:hover:bg-opacity-[0.95]'}"
|
||||
>
|
||||
Financials
|
||||
Holdings
|
||||
</a>
|
||||
<a
|
||||
href={`/etf/${$etfTicker}/statistics`}
|
||||
on:click={() => changeSection("statistics")}
|
||||
class="p-2 px-5 cursor-pointer {displaySection ===
|
||||
'statistics'
|
||||
? 'text-white bg-[#27272A] sm:hover:bg-opacity-[0.95]'
|
||||
: 'text-gray-400 sm:hover:text-white sm:hover:bg-[#27272A] sm:hover:bg-opacity-[0.95]'}"
|
||||
>Statistics</a
|
||||
>
|
||||
|
||||
{#if ["amd", "save", "ba", "adbe", "nflx", "pltr", "msft", "meta", "tsla", "nvda", "aapl", "gme"]?.includes($etfTicker?.toLowerCase())}
|
||||
<a
|
||||
href={`/etf/${$etfTicker}/metrics`}
|
||||
on:click={() => changeSection("metrics")}
|
||||
class="p-2 px-5 cursor-pointer {displaySection ===
|
||||
'metrics'
|
||||
? 'text-white bg-[#27272A] sm:hover:bg-opacity-[0.95]'
|
||||
: 'text-gray-400 sm:hover:text-white sm:hover:bg-[#27272A] sm:hover:bg-opacity-[0.95]'}"
|
||||
>Metrics</a
|
||||
>
|
||||
{/if}
|
||||
|
||||
{#if Object?.keys(data?.getAnalystRating ?? {})?.length > 0}
|
||||
<a
|
||||
href={`/etf/${$etfTicker}/forecast`}
|
||||
on:click={() => changeSection("forecast")}
|
||||
class="p-2 px-5 cursor-pointer {displaySection ===
|
||||
'forecast'
|
||||
? 'text-white bg-[#27272A] sm:hover:bg-opacity-[0.95]'
|
||||
: 'text-gray-400 sm:hover:text-white sm:hover:bg-[#27272A] sm:hover:bg-opacity-[0.95]'}"
|
||||
>
|
||||
Forecast
|
||||
</a>
|
||||
{/if}
|
||||
<a
|
||||
href={`/etf/${$etfTicker}/options`}
|
||||
on:click={() => changeSection("options")}
|
||||
|
||||
@ -1351,12 +1351,20 @@
|
||||
class="flex flex-col border-b border-gray-600 py-1 sm:table-row sm:py-0"
|
||||
><td
|
||||
class="whitespace-nowrap px-0.5 py-[1px] xs:px-1 sm:py-2"
|
||||
>Short % of Shares Out</td
|
||||
>Inception Date</td
|
||||
>
|
||||
<td
|
||||
class="whitespace-nowrap px-0.5 py-[1px] text-left text-smaller font-semibold tiny:text-base xs:px-1 sm:py-2 sm:text-right sm:text-small"
|
||||
>{stockDeck?.shortOutStandingPercent !== null
|
||||
? stockDeck?.shortOutStandingPercent + "%"
|
||||
>{stockDeck?.inceptionDate !== null
|
||||
? new Date(stockDeck?.inceptionDate)?.toLocaleString(
|
||||
"en-US",
|
||||
{
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
daySuffix: "2-digit",
|
||||
},
|
||||
)
|
||||
: "n/a"}</td
|
||||
></tr
|
||||
>
|
||||
|
||||
@ -1,607 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import {
|
||||
displayCompanyName,
|
||||
numberOfUnreadNotification,
|
||||
etfTicker,
|
||||
} from "$lib/store";
|
||||
import republicanBackground from "$lib/images/bg-republican.png";
|
||||
import democraticBackground from "$lib/images/bg-democratic.png";
|
||||
import otherBackground from "$lib/images/bg-other.png";
|
||||
import { getPartyForPoliticians } from "$lib/utils";
|
||||
|
||||
export let data;
|
||||
|
||||
let rawData = data?.getSenateTrading;
|
||||
let buySellRatio = 0;
|
||||
let partyRatio = 0;
|
||||
let senateTradingList = [];
|
||||
let displayStructure = "Card";
|
||||
let isLoaded = false;
|
||||
|
||||
let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
|
||||
|
||||
function backToTop() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
});
|
||||
}
|
||||
|
||||
function changeStructure() {
|
||||
if (displayStructure === "Card") {
|
||||
displayStructure = "Table";
|
||||
} else {
|
||||
displayStructure = "Card";
|
||||
}
|
||||
}
|
||||
|
||||
const district = {
|
||||
Tommy_Tuberville: "Alabama",
|
||||
Sheldon_Whitehouse: "Rhode Island",
|
||||
Pat_Toomey: "Pennsylvania",
|
||||
Tom_Carper: "Delaware",
|
||||
Pat_Roberts: "Kansas",
|
||||
Markwayne_Mullin: "Oklahoma",
|
||||
Shelley_Capito: "West Virginia",
|
||||
Jerry_Moran: "Kansas",
|
||||
Dan_Sullivan: "Alaska",
|
||||
Ron_Wyden: "Oregon",
|
||||
John_Hickenlooper: "Colorado",
|
||||
David_Perdue: "Georgia",
|
||||
Kelly_Loeffler: "Georgia",
|
||||
Bill_Cassidy: "Louisiana",
|
||||
};
|
||||
|
||||
async function handleScroll() {
|
||||
const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height
|
||||
const isBottom = window.innerHeight + window.scrollY >= scrollThreshold;
|
||||
if (isBottom && senateTradingList?.length !== rawData?.length) {
|
||||
const nextIndex = senateTradingList?.length;
|
||||
const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 25);
|
||||
senateTradingList = [...senateTradingList, ...filteredNewResults];
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
rawData.forEach((item) => {
|
||||
const representative = item?.representative || "";
|
||||
const fullName = representative
|
||||
.replace(/(\s(?:Dr\s)?\w(?:\.|(?=\s)))?\s/g, "_")
|
||||
.trim();
|
||||
item.representative = fullName.replace(/_/g, " ");
|
||||
});
|
||||
|
||||
rawData = rawData?.map((item) => {
|
||||
const party = getPartyForPoliticians(item?.representative);
|
||||
return {
|
||||
...item,
|
||||
party: party,
|
||||
};
|
||||
});
|
||||
|
||||
// Count the occurrences of "Republican" and "Democrat"
|
||||
const partyCounts = rawData.reduce((counts, item) => {
|
||||
counts[item?.party] = (counts[item?.party] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
|
||||
const typeCounts = rawData.reduce((counts, item) => {
|
||||
counts[item?.type] = (counts[item?.type] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
|
||||
partyRatio =
|
||||
partyCounts["Democratic"] > 0 && partyCounts["Republican"] === undefined
|
||||
? 1
|
||||
: partyCounts["Democratic"] === undefined
|
||||
? 0
|
||||
: partyCounts["Democratic"] / partyCounts["Republican"];
|
||||
buySellRatio =
|
||||
typeCounts["Bought"] > 0 && typeCounts["Sold"] === undefined
|
||||
? 1
|
||||
: typeCounts["Bought"] === undefined
|
||||
? 0
|
||||
: typeCounts["Bought"] / typeCounts["Sold"];
|
||||
|
||||
senateTradingList = rawData.slice(0, 20) ?? [];
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
if (data?.user?.tier === "Pro") {
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
return () => {
|
||||
window.removeEventListener("scroll", handleScroll);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>
|
||||
{$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""}
|
||||
{$displayCompanyName} ({$etfTicker}) US Congress & Senate Trading ·
|
||||
stocknear
|
||||
</title>
|
||||
<meta
|
||||
name="description"
|
||||
content={`Get the latest US congress & senate trading of ${$displayCompanyName} (${$etfTicker}) from democrates and republicans.`}
|
||||
/>
|
||||
|
||||
<!-- Other meta tags -->
|
||||
<meta
|
||||
property="og:title"
|
||||
content={`${$displayCompanyName} (${$etfTicker}) US Congress & Senate Trading · stocknear`}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={`Get the latest US congress & senate trading of ${$displayCompanyName} (${$etfTicker}) from democrates and republicans.`}
|
||||
/>
|
||||
<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={`${$displayCompanyName} (${$etfTicker}) US Congress & Senate Trading · stocknear`}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:description"
|
||||
content={`Get the latest US congress & senate trading of ${$displayCompanyName} (${$etfTicker}) from democrates and republicans.`}
|
||||
/>
|
||||
<!-- Add more Twitter meta tags as needed -->
|
||||
</svelte:head>
|
||||
|
||||
<section
|
||||
class="w-full bg-[#09090B] overflow-hidden text-white h-full mb-40 sm:mb-0"
|
||||
>
|
||||
<div class="h-full overflow-hidden">
|
||||
<div class="relative flex justify-center items-center overflow-hidden">
|
||||
<div class="sm:p-7 w-full mt-2 sm:mt-0">
|
||||
<div class="mb-6">
|
||||
<h1 class="text-xl sm:text-2xl text-white font-bold mb-4">
|
||||
Congress Trading
|
||||
</h1>
|
||||
|
||||
<div
|
||||
class="text-white 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]"
|
||||
>
|
||||
<svg
|
||||
class="w-6 h-6 flex-shrink-0 inline-block sm:mr-2"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 256 256"
|
||||
><path
|
||||
fill="#fff"
|
||||
d="M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24m-4 48a12 12 0 1 1-12 12a12 12 0 0 1 12-12m12 112a16 16 0 0 1-16-16v-40a8 8 0 0 1 0-16a16 16 0 0 1 16 16v40a8 8 0 0 1 0 16"
|
||||
/></svg
|
||||
>
|
||||
Get detailed insights of Corrupt US Politician 🇺🇸 who bought or sold
|
||||
{$displayCompanyName} and the amounts involved!
|
||||
</div>
|
||||
</div>
|
||||
{#if isLoaded}
|
||||
{#if senateTradingList?.length !== 0}
|
||||
<h3 class="text-white text-xl font-semibold pt-5">
|
||||
Congress Statistics
|
||||
</h3>
|
||||
<!--Start Widget-->
|
||||
<div
|
||||
class="w-full mt-5 mb-10 m-auto flex justify-center items-center"
|
||||
>
|
||||
<div
|
||||
class="w-full grid grid-cols-2 sm:grid-cols-3 gap-y-3 lg:gap-y-3 gap-x-3"
|
||||
>
|
||||
<!--Start Buy/Sell-->
|
||||
<div
|
||||
class="flex flex-row items-center flex-wrap w-full px-3 sm:px-4 bg-[#262626] shadow-lg rounded-lg h-20"
|
||||
>
|
||||
<div class="flex flex-col items-start">
|
||||
<span
|
||||
class="font-semibold text-gray-200 text-sm sm:text-[1rem]"
|
||||
>Buy/Sell</span
|
||||
>
|
||||
<span
|
||||
class="text-start text-sm sm:text-[1rem] font-medium text-white"
|
||||
>
|
||||
{buySellRatio?.toFixed(3)}
|
||||
</span>
|
||||
</div>
|
||||
<!-- Circular Progress -->
|
||||
<div class="relative size-14 ml-auto">
|
||||
<svg
|
||||
class="size-full w-14 h-14"
|
||||
viewBox="0 0 36 36"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<!-- Background Circle -->
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current text-[#3E3E3E]"
|
||||
stroke-width="3"
|
||||
></circle>
|
||||
<!-- Progress Circle inside a group with rotation -->
|
||||
<g class="origin-center -rotate-90 transform">
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current {buySellRatio >= 0.5
|
||||
? 'text-[#00FC50]'
|
||||
: 'text-[#EE5365]'} "
|
||||
stroke-width="3"
|
||||
stroke-dasharray="100"
|
||||
stroke-dashoffset={100 - buySellRatio * 100 >= 0
|
||||
? 100 - (buySellRatio * 100)?.toFixed(2)
|
||||
: 0}
|
||||
></circle>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Percentage Text -->
|
||||
<div
|
||||
class="absolute top-1/2 start-1/2 transform -translate-y-1/2 -translate-x-1/2"
|
||||
>
|
||||
<span
|
||||
class="text-center text-white text-sm sm:text-[1rem]"
|
||||
>{buySellRatio?.toFixed(2)}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Circular Progress -->
|
||||
</div>
|
||||
<!--End Buy/Sell-->
|
||||
<!--Start Dem/Rep-->
|
||||
<div
|
||||
class="flex flex-row items-center flex-wrap w-full px-3 sm:px-4 bg-[#262626] shadow-lg rounded-lg h-20"
|
||||
>
|
||||
<div class="flex flex-col items-start">
|
||||
<span
|
||||
class="font-semibold text-gray-200 text-sm sm:text-[1rem]"
|
||||
>Dem/Rep</span
|
||||
>
|
||||
<span
|
||||
class="text-start text-sm sm:text-[1rem] font-medium text-white"
|
||||
>
|
||||
{partyRatio?.toFixed(3)}
|
||||
</span>
|
||||
</div>
|
||||
<!-- Circular Progress -->
|
||||
<div class="relative size-14 ml-auto">
|
||||
<svg
|
||||
class="size-full w-14 h-14"
|
||||
viewBox="0 0 36 36"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<!-- Background Circle -->
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current text-[#3E3E3E]"
|
||||
stroke-width="3"
|
||||
></circle>
|
||||
<!-- Progress Circle inside a group with rotation -->
|
||||
<g class="origin-center -rotate-90 transform">
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current text-blue-500"
|
||||
stroke-width="3"
|
||||
stroke-dasharray="100"
|
||||
stroke-dashoffset={100 - partyRatio * 100 >= 0
|
||||
? 100 - (partyRatio * 100)?.toFixed(2)
|
||||
: 0}
|
||||
></circle>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Percentage Text -->
|
||||
<div
|
||||
class="absolute top-1/2 start-1/2 transform -translate-y-1/2 -translate-x-1/2"
|
||||
>
|
||||
<span
|
||||
class="text-center text-white text-sm sm:text-[1rem]"
|
||||
>{partyRatio?.toFixed(2)}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Circular Progress -->
|
||||
</div>
|
||||
<!--End Put/Call-->
|
||||
</div>
|
||||
</div>
|
||||
<!--End Widget-->
|
||||
|
||||
<label
|
||||
on:click={changeStructure}
|
||||
class="sm:hidden w-24 sm:ml-3 mr-2 sm:mr-0 cursor-pointer bg-[#27272A] px-4 py-2 rounded-lg shadow-md"
|
||||
>
|
||||
<span class="m-auto mr-0.5 text-white text-sm">
|
||||
Switch To: {displayStructure}
|
||||
</span>
|
||||
</label>
|
||||
|
||||
{#if displayStructure === "Card"}
|
||||
<div
|
||||
class="mt-6 flex justify-start items-center w-full m-auto rounded-none sm:rounded-lg mb-4 overflow-x-scroll"
|
||||
>
|
||||
<table
|
||||
class="table table-sm sm:table-md table-compact rounded-none sm:rounded-md w-full bg-[#09090B] border-bg-[#09090B] m-auto"
|
||||
>
|
||||
<thead>
|
||||
<tr class="bg-[#09090B]">
|
||||
<th
|
||||
class="shadow-md text-start bg-[#09090B] text-white text-sm font-semibold"
|
||||
>
|
||||
Person
|
||||
</th>
|
||||
<th
|
||||
class="shadow-md text-end bg-[#09090B] text-white text-sm font-semibold"
|
||||
>
|
||||
Transaction Date
|
||||
</th>
|
||||
<th
|
||||
class="shadow-md text-end bg-[#09090B] text-white text-sm font-semibold"
|
||||
>
|
||||
Amount
|
||||
</th>
|
||||
<th
|
||||
class="shadow-md text-white font-semibold text-end text-sm"
|
||||
>Type</th
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each senateTradingList as item}
|
||||
<tr
|
||||
class="odd:bg-[#27272A] sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] bg-[#09090B] border-b-[#09090B]"
|
||||
>
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] whitespace-nowrap pb-3 border-b border-b-[#09090B]"
|
||||
>
|
||||
<div class="flex flex-row items-center">
|
||||
<div
|
||||
class="flex-shrink-0 rounded-full border border-slate-700 w-10 h-10 sm:w-12 sm:h-12 relative {item?.party ===
|
||||
'Republican'
|
||||
? 'bg-[#98272B]'
|
||||
: item?.party === 'Democratic'
|
||||
? 'bg-[#295AC7]'
|
||||
: 'bg-[#4E2153]'} flex items-center justify-center"
|
||||
>
|
||||
<img
|
||||
style="clip-path: circle(50%);"
|
||||
class="avatar rounded-full w-7 sm:w-9"
|
||||
src={`${cloudFrontUrl}/assets/senator/${item?.representative?.replace(/\s+/g, "_")}.png`}
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col ml-3">
|
||||
<a
|
||||
href={`/politicians/${item?.id}`}
|
||||
class="sm:hover:text-white text-blue-400"
|
||||
>{item?.representative?.replace("_", " ")}</a
|
||||
>
|
||||
<span class="">{item?.party}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!--{item?.firstName} {item?.lastName}-->
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-b-[#09090B]"
|
||||
>
|
||||
{new Date(item?.transactionDate)?.toLocaleString(
|
||||
"en-US",
|
||||
{
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
daySuffix: "2-digit",
|
||||
},
|
||||
)}
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-b-[#09090B]"
|
||||
>
|
||||
{item?.amount}
|
||||
</td>
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-b-[#09090B]"
|
||||
>
|
||||
{#if item?.type === "Bought"}
|
||||
<span class="text-[#00FC50]">Bought</span>
|
||||
{:else if item?.type === "Sold"}
|
||||
<span class="text-[#FF2F1F]">Sold</span>
|
||||
{:else if item?.type === "Exchange"}
|
||||
<span class="text-[#C6A755]">Exchange</span>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="relative w-full mt-10">
|
||||
{#each senateTradingList as item}
|
||||
<div
|
||||
class="w-full bg-[#09090B] border border-slate-800 shadow-lg h-auto pb-4 pt-4 mb-7"
|
||||
>
|
||||
<div class="flex flex-col relative">
|
||||
{#if item?.party === "Republican"}
|
||||
<img
|
||||
class="absolute -mt-4 w-full m-auto"
|
||||
src={republicanBackground}
|
||||
/>
|
||||
{:else if item?.party === "Democratic"}
|
||||
<img
|
||||
class="absolute -mt-4 w-[500px] m-auto"
|
||||
src={democraticBackground}
|
||||
/>
|
||||
{:else}
|
||||
<img
|
||||
class="absolute -mt-4 w-[500px] m-auto"
|
||||
src={otherBackground}
|
||||
/>
|
||||
{/if}
|
||||
<div
|
||||
class="flex flex-col justify-center items-center rounded-lg"
|
||||
>
|
||||
<div
|
||||
class="-mt-3 shadow-lg rounded-full border border-slate-600 w-20 h-20 relative {item?.party ===
|
||||
'Republican'
|
||||
? 'bg-[#98272B]'
|
||||
: item?.party === 'Democratic'
|
||||
? 'bg-[#295AC7]'
|
||||
: 'bg-[#20202E]'} flex items-center justify-center"
|
||||
>
|
||||
<img
|
||||
style="clip-path: circle(50%);"
|
||||
class="rounded-full w-16"
|
||||
src={`${cloudFrontUrl}/assets/senator/${item?.representative?.replace(/\s+/g, "_")}.png`}
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
<span class="text-white text-lg font-medium mt-2 mb-2">
|
||||
{item?.representative?.replace("_", " ")}
|
||||
</span>
|
||||
<span class="text-white text-md mb-8">
|
||||
{item?.party ?? "n/a"} / {district[
|
||||
item?.representative
|
||||
] ?? "n/a"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row items-center pr-4 pl-4">
|
||||
<div class="flex flex-col justify-start items-start">
|
||||
<span class="font-medium text-white">Owner</span>
|
||||
<span
|
||||
class="text-white text-opacity-[0.8] text-sm text-end"
|
||||
>
|
||||
{item?.owner?.length !== 0 ? item?.owner : "-"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="border-1 border-b border-slate-800 w-full mt-5 mb-5"
|
||||
/>
|
||||
|
||||
<div class="flex flex-row items-center pr-4 pl-4">
|
||||
<div class="flex flex-col w-40">
|
||||
<span class="font-medium text-white"
|
||||
>Transaction Date</span
|
||||
>
|
||||
<span class="text-slate-300 text-sm">
|
||||
{new Date(item?.transactionDate)?.toLocaleString(
|
||||
"en-US",
|
||||
{
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
daySuffix: "2-digit",
|
||||
},
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex flex-col justify-end items-end ml-auto"
|
||||
>
|
||||
<span class="font-medium text-white"
|
||||
>Disclosure Date</span
|
||||
>
|
||||
<span
|
||||
class="text-white text-opacity-[0.8] text-sm text-end"
|
||||
>
|
||||
{new Date(item?.disclosureDate)?.toLocaleString(
|
||||
"en-US",
|
||||
{
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
daySuffix: "2-digit",
|
||||
},
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="border-1 border-b border-slate-800 w-full mt-5 mb-5"
|
||||
/>
|
||||
|
||||
<div class="flex flex-row items-center pr-4 pl-4">
|
||||
<div class="flex flex-col w-40">
|
||||
<span class="font-medium text-white">Amount</span>
|
||||
<span class="text-slate-300 text-sm font-medium">
|
||||
{item?.amount?.replace(
|
||||
"$1,000,001 - $5,000,000",
|
||||
"$1Mio - $5Mio",
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex flex-col justify-end items-end ml-auto"
|
||||
>
|
||||
<span class="font-medium text-slate-300 text-ends"
|
||||
>Type</span
|
||||
>
|
||||
<span class="text-white font-medium text-end">
|
||||
{#if item?.type === "Bought"}
|
||||
<span class="text-[#00FC50]">Bought</span>
|
||||
{:else if item?.type === "Sold"}
|
||||
<span class="text-[#FF2F1F]">Sold</span>
|
||||
{:else if item?.type === "Exchange"}
|
||||
<span class="text-[#C6A755]">Exchange</span>
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
{#if rawData?.length >= 20}
|
||||
<label
|
||||
on:click={backToTop}
|
||||
class="w-32 py-1.5 mt-10 hover:bg-white hover:bg-opacity-[0.05] cursor-pointer m-auto flex justify-center items-center border border-slate-800 rounded-full"
|
||||
>
|
||||
Back to top
|
||||
</label>
|
||||
{/if}
|
||||
{/if}
|
||||
{:else}
|
||||
<h2
|
||||
class="pl-4 pr-4 flex justify-center items-center text-md sm:text-lg text-center text-slate-200"
|
||||
>
|
||||
No trading history available for {$displayCompanyName}. Likely no
|
||||
corrupt politican has interest in this stock.
|
||||
</h2>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="flex justify-center items-center h-80">
|
||||
<div class="relative">
|
||||
<label
|
||||
class="bg-[#09090B] rounded-xl h-14 w-14 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
|
||||
>
|
||||
<span class="loading loading-spinner loading-md text-gray-400"
|
||||
></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
28
src/routes/etf/[tickerID]/dividends/+layout.server.ts
Normal file
28
src/routes/etf/[tickerID]/dividends/+layout.server.ts
Normal file
@ -0,0 +1,28 @@
|
||||
export const load = async ({ locals, params }) => {
|
||||
|
||||
const getSimilarStocks = async () => {
|
||||
const { apiKey, apiURL } = locals;
|
||||
const postData = {
|
||||
ticker: params.tickerID,
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + "/similar-stocks", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
// Make sure to return a promise
|
||||
return {
|
||||
getSimilarStocks: await getSimilarStocks(),
|
||||
};
|
||||
};
|
||||
87
src/routes/etf/[tickerID]/dividends/+layout.svelte
Normal file
87
src/routes/etf/[tickerID]/dividends/+layout.svelte
Normal file
@ -0,0 +1,87 @@
|
||||
<script lang="ts">
|
||||
import ArrowLogo from "lucide-svelte/icons/move-up-right";
|
||||
|
||||
export let data;
|
||||
|
||||
const similarStocks = data?.getSimilarStocks?.sort(
|
||||
(a, b) => b?.dividendYield - a?.dividendYield,
|
||||
);
|
||||
</script>
|
||||
|
||||
<section class="w-auto overflow-hidden min-h-screen">
|
||||
<div class="w-full overflow-hidden m-auto">
|
||||
<div class="sm:p-0 flex justify-center w-full m-auto overflow-hidden">
|
||||
<div
|
||||
class="relative flex justify-center items-start overflow-hidden w-full"
|
||||
>
|
||||
<main class="w-full lg:w-3/4">
|
||||
<slot />
|
||||
</main>
|
||||
|
||||
<aside class="hidden lg:block relative fixed w-1/4 ml-4">
|
||||
{#if data?.user?.tier !== "Pro" || data?.user?.freeTrial}
|
||||
<div
|
||||
class="w-full border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
|
||||
>
|
||||
<a
|
||||
href="/pricing"
|
||||
class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"
|
||||
>
|
||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||
Pro Subscription
|
||||
</h2>
|
||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0" />
|
||||
</div>
|
||||
<span class="text-white p-3 ml-3 mr-3">
|
||||
Upgrade now for unlimited access to all data and tools.
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if similarStocks?.length > 0}
|
||||
<div
|
||||
class="w-full p-2 text-white border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
|
||||
>
|
||||
<h3 class="p-2 pt-4 text-xl font-semibold">Related Stocks</h3>
|
||||
<table class="table table-sm table-compact w-full text-white">
|
||||
<thead class="text-white"
|
||||
><tr
|
||||
><th
|
||||
class="whitespace-nowrap border-b font-semibold text-sm text-left"
|
||||
>Company</th
|
||||
>
|
||||
<th
|
||||
class="whitespace-nowrap border-b font-semibold text-sm text-right"
|
||||
>Dividend Yield</th
|
||||
></tr
|
||||
></thead
|
||||
>
|
||||
<tbody>
|
||||
{#each similarStocks?.slice(0, 8) as item}
|
||||
<tr class="border-gray-600 border-b"
|
||||
><td class="text-left"
|
||||
><a
|
||||
href={`/stocks/${item?.symbol}`}
|
||||
class="sm:hover:text-white text-blue-400"
|
||||
>{item?.symbol}</a
|
||||
></td
|
||||
>
|
||||
<td class="text-right cursor-normal"
|
||||
>{item?.dividendYield !== null &&
|
||||
item?.dividendYield !== undefined
|
||||
? item?.dividendYield + "%"
|
||||
: "n/a"}</td
|
||||
>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/if}
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@ -1,6 +1,9 @@
|
||||
export const load = async ({ locals, params }) => {
|
||||
export const load = async ({ params, locals }) => {
|
||||
const getStockDividend = async () => {
|
||||
const { apiKey, apiURL } = locals;
|
||||
let newsList;
|
||||
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = {
|
||||
ticker: params.tickerID,
|
||||
};
|
||||
@ -15,9 +18,9 @@ export const load = async ({ locals, params }) => {
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
newsList = await response.json();
|
||||
|
||||
return output;
|
||||
return newsList;
|
||||
};
|
||||
|
||||
// Make sure to return a promise
|
||||
|
||||
@ -81,6 +81,9 @@
|
||||
data: dividendList,
|
||||
type: "bar",
|
||||
smooth: true,
|
||||
itemStyle: {
|
||||
color: "#fff",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -132,21 +135,19 @@
|
||||
<!-- Add more Twitter meta tags as needed -->
|
||||
</svelte:head>
|
||||
|
||||
<section
|
||||
class="w-full bg-[#09090B] overflow-hidden text-white h-full mb-40 sm:mb-0"
|
||||
>
|
||||
<section class="w-full bg-[#09090B] overflow-hidden text-white h-full">
|
||||
<div class="w-full flex h-full overflow-hidden">
|
||||
<div
|
||||
class="w-full relative flex justify-center items-center overflow-hidden"
|
||||
>
|
||||
<div class="sm:p-7 w-full m-auto mt-2 sm:mt-0">
|
||||
<div class="w-full mb-6">
|
||||
<h1 class="text-xl sm:text-2xl text-white font-bold mb-4">
|
||||
<h1 class="text-xl sm:text-2xl text-gray-200 font-bold mb-4 w-full">
|
||||
Dividends
|
||||
</h1>
|
||||
|
||||
<div
|
||||
class="w-full text-white text-start 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]"
|
||||
class="w-full text-white text-start p-3 sm:p-5 mb-10 rounded-md sm:flex sm:flex-row sm:items-center border border-gray-600 text-sm sm:text-[1rem]"
|
||||
>
|
||||
<svg
|
||||
class="w-6 h-6 flex-shrink-0 inline-block sm:mr-2"
|
||||
@ -191,14 +192,16 @@
|
||||
dividends for over 12 months.
|
||||
{/if}
|
||||
{:else}
|
||||
No dividend history available for {$displayCompanyName}.
|
||||
<div class="w-full">
|
||||
No dividend history available for {$displayCompanyName}.
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if rawData?.history?.length !== 0}
|
||||
<div
|
||||
class="mb-4 grid grid-cols-2 grid-rows-1 divide-gray-500 rounded-lg border border-gray-600 bg-[#272727] shadow md:grid-cols-3 md:grid-rows-1 divide-x"
|
||||
class="mb-4 grid grid-cols-2 grid-rows-1 divide-gray-600 rounded-md border border-gray-600 md:grid-cols-3 md:grid-rows-1 divide-x"
|
||||
>
|
||||
<div class="p-4 bp:p-5 sm:p-6">
|
||||
<label
|
||||
@ -222,7 +225,7 @@
|
||||
<div
|
||||
class="mt-1 break-words font-semibold leading-8 text-light text-xl"
|
||||
>
|
||||
${annualDividend !== "0.00" ? annualDividend : "0"}
|
||||
{annualDividend !== "0.00" ? annualDividend : "0"}
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4 bp:p-5 sm:p-6 border-r border-contrast">
|
||||
@ -349,7 +352,7 @@
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-[#09090B]"
|
||||
>
|
||||
${item?.adjDividend?.toFixed(3)}
|
||||
{item?.adjDividend?.toFixed(3)}
|
||||
</td>
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-[#09090B]"
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
export const load = async ({ locals, params }) => {
|
||||
const { apiKey, apiURL } = locals;
|
||||
const { apiKey, apiURL, user } = locals;
|
||||
const getETFHoldings = async () => {
|
||||
const postData = {
|
||||
ticker: params.tickerID,
|
||||
};
|
||||
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + "/etf-holdings", {
|
||||
method: "POST",
|
||||
|
||||
@ -4,140 +4,29 @@
|
||||
numberOfUnreadNotification,
|
||||
displayCompanyName,
|
||||
} from "$lib/store";
|
||||
import { Button } from "$lib/components/shadcn/button/index.js";
|
||||
import { screenWidth } from "$lib/store";
|
||||
import { abbreviateNumber, formatString } from "$lib/utils";
|
||||
import { onMount } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import TableHeader from "$lib/components/Table/TableHeader.svelte";
|
||||
import HoverStockChart from "$lib/components/HoverStockChart.svelte";
|
||||
import { formatString } from "$lib/utils";
|
||||
import Table from "$lib/components/Table/Table.svelte";
|
||||
|
||||
export let data;
|
||||
let rawData = data?.getETFHoldings;
|
||||
let holdings = rawData?.slice(0, 50);
|
||||
const excludedRules = new Set([
|
||||
"price",
|
||||
"changesPercentage",
|
||||
"sharesNumber",
|
||||
"weightPercentage",
|
||||
]);
|
||||
|
||||
async function handleScroll() {
|
||||
const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height
|
||||
const isBottom = window.innerHeight + window.scrollY >= scrollThreshold;
|
||||
if (isBottom && holdings?.length !== rawData?.length) {
|
||||
const nextIndex = holdings?.length;
|
||||
const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 25);
|
||||
holdings = [...holdings, ...filteredNewResults];
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
return () => {
|
||||
window.removeEventListener("scroll", handleScroll);
|
||||
};
|
||||
});
|
||||
|
||||
$: charNumber = $screenWidth < 640 ? 20 : 20;
|
||||
|
||||
let columns = [
|
||||
{ key: "asset", label: "Symbol", align: "left" },
|
||||
{ key: "name", label: "Name", align: "left" },
|
||||
{ key: "price", label: "Price", align: "right" },
|
||||
{ key: "changesPercentage", label: "Change", align: "right" },
|
||||
{ key: "sharesNumber", label: "Shares", align: "right" },
|
||||
{ key: "weightPercentage", label: "% Weight", align: "right" },
|
||||
const defaultList = [
|
||||
{ name: "Price", rule: "price" },
|
||||
{ name: "% Change", rule: "changesPercentage" },
|
||||
{ name: "Shares", rule: "sharesNumber" },
|
||||
{ name: "% Weight", rule: "weightPercentage" },
|
||||
];
|
||||
|
||||
let sortOrders = {
|
||||
asset: { order: "none", type: "string" },
|
||||
name: { order: "none", type: "string" },
|
||||
price: { order: "none", type: "number" },
|
||||
changesPercentage: { order: "none", type: "number" },
|
||||
sharesNumber: { order: "none", type: "number" },
|
||||
weightPercentage: { order: "none", type: "number" },
|
||||
};
|
||||
|
||||
const sortData = (key) => {
|
||||
// Reset all other keys to 'none' except the current key
|
||||
for (const k in sortOrders) {
|
||||
if (k !== key) {
|
||||
sortOrders[k].order = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// Cycle through 'none', 'asc', 'desc' for the clicked key
|
||||
const orderCycle = ["none", "asc", "desc"];
|
||||
|
||||
let originalData = rawData;
|
||||
|
||||
const currentOrderIndex = orderCycle.indexOf(sortOrders[key].order);
|
||||
sortOrders[key].order =
|
||||
orderCycle[(currentOrderIndex + 1) % orderCycle.length];
|
||||
const sortOrder = sortOrders[key].order;
|
||||
|
||||
// Reset to original data when 'none' and stop further sorting
|
||||
if (sortOrder === "none") {
|
||||
holdings = [...originalData]?.slice(0, 50); // Reset to original data (spread to avoid mutation)
|
||||
return;
|
||||
}
|
||||
|
||||
// Define a generic comparison function
|
||||
const compareValues = (a, b) => {
|
||||
const { type } = sortOrders[key];
|
||||
let valueA, valueB;
|
||||
|
||||
switch (type) {
|
||||
case "date":
|
||||
valueA = new Date(a[key]);
|
||||
valueB = new Date(b[key]);
|
||||
break;
|
||||
case "string":
|
||||
valueA = a[key].toUpperCase();
|
||||
valueB = b[key].toUpperCase();
|
||||
return sortOrder === "asc"
|
||||
? valueA.localeCompare(valueB)
|
||||
: valueB.localeCompare(valueA);
|
||||
case "number":
|
||||
default:
|
||||
valueA = parseFloat(a[key]);
|
||||
valueB = parseFloat(b[key]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (sortOrder === "asc") {
|
||||
return valueA < valueB ? -1 : valueA > valueB ? 1 : 0;
|
||||
} else {
|
||||
return valueA > valueB ? -1 : valueA < valueB ? 1 : 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Sort using the generic comparison function
|
||||
holdings = [...originalData].sort(compareValues)?.slice(0, 50);
|
||||
};
|
||||
|
||||
const exportData = (format = "csv") => {
|
||||
if (data?.user?.tier === "Pro") {
|
||||
// Add headers row
|
||||
const csvRows = [];
|
||||
csvRows.push("Symbol,Name,Price, Change, Shares,Weight");
|
||||
|
||||
// Add data rows
|
||||
rawData.forEach((item) => {
|
||||
const csvRow = `${item?.asset},${item?.name},${item?.price},${item?.changesPercentage},${item?.sharesNumber},${item?.weightPercentage}`;
|
||||
csvRows.push(csvRow);
|
||||
});
|
||||
|
||||
// Create CSV blob and trigger download
|
||||
const csv = csvRows.join("\n");
|
||||
const blob = new Blob([csv], { type: "text/csv" });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.setAttribute("hidden", "");
|
||||
a.setAttribute("href", url);
|
||||
a.setAttribute("download", `${$etfTicker}_holdings.csv`);
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
} else {
|
||||
goto("/pricing");
|
||||
}
|
||||
};
|
||||
const specificRows = [
|
||||
{ name: "% Weight", rule: "weightPercentage", type: "float" },
|
||||
{ name: "Shares", rule: "sharesNumber", type: "int" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@ -215,103 +104,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if holdings?.length !== 0}
|
||||
<div
|
||||
class="flex flex-row items-center justify-end w-fit sm:w-[50%] md:w-auto ml-auto"
|
||||
>
|
||||
<Button
|
||||
on:click={() => exportData("csv")}
|
||||
class="w-fit border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||
>
|
||||
<span class="truncate text-white">Download</span>
|
||||
<svg
|
||||
class="{data?.user?.tier === 'Pro'
|
||||
? 'hidden'
|
||||
: ''} ml-1 -mt-0.5 w-3.5 h-3.5"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
><path
|
||||
fill="#A3A3A3"
|
||||
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
|
||||
/></svg
|
||||
>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="w-full overflow-x-auto mt-5">
|
||||
<table
|
||||
class="table table-sm table-compact rounded-none sm:rounded-md w-full bg-[#09090B] border-bg-[#09090B]"
|
||||
>
|
||||
<thead>
|
||||
<TableHeader {columns} {sortOrders} {sortData} />
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each holdings as item}
|
||||
<!-- row -->
|
||||
{#if item?.asset !== null}
|
||||
<tr
|
||||
class="w-full sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A]"
|
||||
>
|
||||
<td
|
||||
class="text-sm sm:text-[1rem] whitespace-nowrap border-b border-[#09090B]"
|
||||
>
|
||||
<HoverStockChart symbol={item?.asset} />
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] whitespace-nowrap border-b border-[#09090B]"
|
||||
>
|
||||
{item?.name?.length > charNumber
|
||||
? formatString(item?.name?.slice(0, charNumber)) +
|
||||
"..."
|
||||
: formatString(item?.name)}
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] whitespace-nowrap border-b border-[#09090B] text-end"
|
||||
>
|
||||
{item?.price}
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] whitespace-nowrap border-b border-[#09090B] text-end"
|
||||
>
|
||||
{#if item?.changesPercentage >= 0}
|
||||
<span class="text-[#00FC50]"
|
||||
>+{item?.changesPercentage >= 1000
|
||||
? abbreviateNumber(item?.changesPercentage)
|
||||
: item?.changesPercentage?.toFixed(2)}%</span
|
||||
>
|
||||
{:else if item?.changesPercentage < 0}
|
||||
<span class="text-[#FF2F1F]"
|
||||
>{item?.changesPercentage <= -1000
|
||||
? abbreviateNumber(item?.changesPercentage)
|
||||
: item?.changesPercentage?.toFixed(2)}%
|
||||
</span>
|
||||
{:else}
|
||||
-
|
||||
{/if}
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] whitespace-nowrap border-b border-[#09090B] text-end"
|
||||
>
|
||||
{abbreviateNumber(item?.sharesNumber)}
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] whitespace-nowrap border-b border-[#09090B] text-end"
|
||||
>
|
||||
{item?.weightPercentage >= 0.01
|
||||
? item?.weightPercentage?.toFixed(2)
|
||||
: "< 0.01"}%
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{#if rawData?.length !== 0}
|
||||
<Table
|
||||
{data}
|
||||
{rawData}
|
||||
{excludedRules}
|
||||
{defaultList}
|
||||
{specificRows}
|
||||
/>
|
||||
{:else}
|
||||
<h2
|
||||
class="pl-4 pr-4 flex justify-center items-center text-md sm:text-lg text-center text-slate-200"
|
||||
|
||||
136
src/routes/etf/[tickerID]/insider/+layout.svelte
Normal file
136
src/routes/etf/[tickerID]/insider/+layout.svelte
Normal file
@ -0,0 +1,136 @@
|
||||
<script lang="ts">
|
||||
import { etfTicker } from "$lib/store";
|
||||
import ArrowLogo from "lucide-svelte/icons/move-up-right";
|
||||
|
||||
export let data;
|
||||
|
||||
let newsList = data?.getNews ?? [];
|
||||
|
||||
const formatDate = (dateString) => {
|
||||
// Create a date object for the input dateString
|
||||
const inputDate = new Date(dateString);
|
||||
|
||||
// Create a date object for the current time in New York City
|
||||
const nycTime = new Date().toLocaleString("en-US", {
|
||||
timeZone: "America/New_York",
|
||||
});
|
||||
const currentNYCDate = new Date(nycTime);
|
||||
|
||||
// Calculate the difference in milliseconds
|
||||
const difference = inputDate.getTime() - currentNYCDate.getTime();
|
||||
|
||||
// Convert the difference to minutes
|
||||
const minutes = Math.abs(Math.round(difference / (1000 * 60)));
|
||||
|
||||
if (minutes < 60) {
|
||||
return `${minutes} minutes`;
|
||||
} else if (minutes < 1440) {
|
||||
const hours = Math.round(minutes / 60);
|
||||
return `${hours} hour${hours !== 1 ? "s" : ""}`;
|
||||
} else {
|
||||
const days = Math.round(minutes / 1440);
|
||||
return `${days} day${days !== 1 ? "s" : ""}`;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<section class="w-auto overflow-hidden">
|
||||
<div class="w-full overflow-hidden m-auto">
|
||||
<div class="sm:p-0 flex justify-center w-full m-auto overflow-hidden">
|
||||
<div
|
||||
class="relative flex justify-center items-start overflow-hidden w-full"
|
||||
>
|
||||
<main class="w-full lg:w-3/4">
|
||||
<slot />
|
||||
</main>
|
||||
|
||||
<aside class="hidden lg:block relative fixed w-1/4 ml-4">
|
||||
{#if data?.user?.tier !== "Pro" || data?.user?.freeTrial}
|
||||
<div
|
||||
class="w-full border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
|
||||
>
|
||||
<a
|
||||
href="/pricing"
|
||||
class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"
|
||||
>
|
||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||
Pro Subscription
|
||||
</h2>
|
||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0" />
|
||||
</div>
|
||||
<span class="text-white p-3 ml-3 mr-3">
|
||||
Upgrade now for unlimited access to all data and tools.
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if newsList?.length !== 0}
|
||||
<div
|
||||
class="w-full sm:hover:text-white text-white border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
|
||||
>
|
||||
<div class="p-4 text-sm">
|
||||
<h3 class="text-lg text-white font-semibold mb-3">
|
||||
{$etfTicker} News
|
||||
</h3>
|
||||
<ul class="text-white">
|
||||
{#each newsList?.slice(0, 10) as item}
|
||||
<li class="mb-3 last:mb-1">
|
||||
{formatDate(item?.publishedDate)} ago -
|
||||
<a
|
||||
class="sm:hover:text-white text-blue-400"
|
||||
href={item?.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer nofollow">{item?.title}</a
|
||||
>
|
||||
- {item?.site}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style lang="scss">
|
||||
.scrollbar {
|
||||
display: grid;
|
||||
grid-gap: 17px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
|
||||
grid-auto-flow: column;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: thin; /* Hide the default scrollbar in Firefox */
|
||||
scrollbar-color: transparent transparent; /* Hide the default scrollbar in Firefox */
|
||||
}
|
||||
|
||||
/* Custom scrollbar for Webkit (Chrome, Safari) */
|
||||
.scrollbar::-webkit-scrollbar {
|
||||
width: 0; /* Hide the width of the scrollbar */
|
||||
height: 0; /* Hide the height of the scrollbar */
|
||||
}
|
||||
|
||||
.scrollbar::-webkit-scrollbar-thumb {
|
||||
background: transparent; /* Make the thumb transparent */
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
height: 7px;
|
||||
width: 10px;
|
||||
background: #09090b;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #6b6f79;
|
||||
-webkit-border-radius: 1ex;
|
||||
-webkit-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.75);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
background: #09090b;
|
||||
}
|
||||
</style>
|
||||
427
src/routes/etf/[tickerID]/insider/+page.svelte
Normal file
427
src/routes/etf/[tickerID]/insider/+page.svelte
Normal file
@ -0,0 +1,427 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import {
|
||||
displayCompanyName,
|
||||
numberOfUnreadNotification,
|
||||
etfTicker,
|
||||
} from "$lib/store";
|
||||
import { getPartyForPoliticians } from "$lib/utils";
|
||||
|
||||
export let data;
|
||||
|
||||
let rawData = data?.getSenateTrading;
|
||||
let buySellRatio = 0;
|
||||
let partyRatio = 0;
|
||||
let senateTradingList = [];
|
||||
let isLoaded = false;
|
||||
|
||||
let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL;
|
||||
|
||||
function getAbbreviatedName(fullName) {
|
||||
if (fullName === null) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
const names = fullName?.split(" ");
|
||||
let firstName = names[0];
|
||||
// Remove any title prefix (e.g. Dr., Mr., Mrs., Ms.)
|
||||
if (names.length > 1 && /^(Dr|Mr|Mrs|Ms)\.?$/i.test(names[0])) {
|
||||
firstName = names[1];
|
||||
names?.splice(0, 1);
|
||||
}
|
||||
const initials = names
|
||||
?.slice(0, -1)
|
||||
?.map((name) => name?.charAt(0))
|
||||
?.join(". ");
|
||||
const lastName = names[names?.length - 1];
|
||||
return `${firstName?.charAt(0)}. ${lastName}`;
|
||||
}
|
||||
|
||||
function backToTop() {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
});
|
||||
}
|
||||
|
||||
async function handleScroll() {
|
||||
const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height
|
||||
const isBottom = window.innerHeight + window.scrollY >= scrollThreshold;
|
||||
if (isBottom && senateTradingList?.length !== rawData?.length) {
|
||||
const nextIndex = senateTradingList?.length;
|
||||
const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50);
|
||||
senateTradingList = [...senateTradingList, ...filteredNewResults];
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
rawData.forEach((item) => {
|
||||
const representative = item?.representative || "";
|
||||
const fullName = representative
|
||||
.replace(/(\s(?:Dr\s)?\w(?:\.|(?=\s)))?\s/g, "_")
|
||||
.trim();
|
||||
item.representative = fullName.replace(/_/g, " ");
|
||||
});
|
||||
|
||||
rawData = rawData?.map((item) => {
|
||||
const party = getPartyForPoliticians(item?.representative);
|
||||
return {
|
||||
...item,
|
||||
party: party,
|
||||
};
|
||||
});
|
||||
|
||||
// Count the occurrences of "Republican" and "Democrat"
|
||||
const partyCounts = rawData.reduce((counts, item) => {
|
||||
counts[item?.party] = (counts[item?.party] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
|
||||
const typeCounts = rawData.reduce((counts, item) => {
|
||||
counts[item?.type] = (counts[item?.type] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
|
||||
partyRatio =
|
||||
partyCounts["Democratic"] > 0 && partyCounts["Republican"] === undefined
|
||||
? 1
|
||||
: partyCounts["Democratic"] === undefined
|
||||
? 0
|
||||
: partyCounts["Democratic"] / partyCounts["Republican"];
|
||||
buySellRatio =
|
||||
typeCounts["Bought"] > 0 && typeCounts["Sold"] === undefined
|
||||
? 1
|
||||
: typeCounts["Bought"] === undefined
|
||||
? 0
|
||||
: typeCounts["Bought"] / typeCounts["Sold"];
|
||||
|
||||
senateTradingList = rawData.slice(0, 20) ?? [];
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
return () => {
|
||||
window.removeEventListener("scroll", handleScroll);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>
|
||||
{$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""}
|
||||
{$displayCompanyName} ({$etfTicker}) US Congress & Senate Trading ·
|
||||
stocknear
|
||||
</title>
|
||||
<meta
|
||||
name="description"
|
||||
content={`Get the latest US congress & senate trading of ${$displayCompanyName} (${$etfTicker}) from democrates and republicans.`}
|
||||
/>
|
||||
|
||||
<!-- Other meta tags -->
|
||||
<meta
|
||||
property="og:title"
|
||||
content={`${$displayCompanyName} (${$etfTicker}) US Congress & Senate Trading · stocknear`}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={`Get the latest US congress & senate trading of ${$displayCompanyName} (${$etfTicker}) from democrates and republicans.`}
|
||||
/>
|
||||
<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={`${$displayCompanyName} (${$etfTicker}) US Congress & Senate Trading · stocknear`}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:description"
|
||||
content={`Get the latest US congress & senate trading of ${$displayCompanyName} (${$etfTicker}) from democrates and republicans.`}
|
||||
/>
|
||||
<!-- Add more Twitter meta tags as needed -->
|
||||
</svelte:head>
|
||||
|
||||
<section
|
||||
class="w-full bg-[#09090B] overflow-hidden min-h-screen text-white h-full"
|
||||
>
|
||||
<div class="h-full overflow-hidden w-full">
|
||||
<div class="relative flex justify-center items-center overflow-hidden">
|
||||
<div class="sm:p-7 w-full mt-2 sm:mt-0">
|
||||
<div class="mb-6">
|
||||
<h1 class="text-xl sm:text-2xl text-white font-bold mb-4">
|
||||
Congress Trading
|
||||
</h1>
|
||||
|
||||
{#if isLoaded}
|
||||
{#if senateTradingList?.length !== 0}
|
||||
<!--Start Widget-->
|
||||
<div
|
||||
class="w-full mt-5 mb-10 m-auto flex justify-center items-center"
|
||||
>
|
||||
<div
|
||||
class="w-full grid grid-cols-2 sm:grid-cols-3 gap-y-3 lg:gap-y-3 gap-x-3"
|
||||
>
|
||||
<!--Start Buy/Sell-->
|
||||
<div
|
||||
class="flex flex-row items-center flex-wrap w-full px-3 sm:px-4 border border-gray-600 rounded-md h-20"
|
||||
>
|
||||
<div class="flex flex-col items-start">
|
||||
<span
|
||||
class="font-semibold text-white text-sm sm:text-[1rem]"
|
||||
>Buy/Sell</span
|
||||
>
|
||||
<span
|
||||
class="text-start text-sm sm:text-[1rem] font-medium text-white"
|
||||
>
|
||||
{buySellRatio?.toFixed(3)}
|
||||
</span>
|
||||
</div>
|
||||
<!-- Circular Progress -->
|
||||
<div class="relative size-14 ml-auto">
|
||||
<svg
|
||||
class="size-full w-14 h-14"
|
||||
viewBox="0 0 36 36"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<!-- Background Circle -->
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current text-[#3E3E3E]"
|
||||
stroke-width="3"
|
||||
></circle>
|
||||
<!-- Progress Circle inside a group with rotation -->
|
||||
<g class="origin-center -rotate-90 transform">
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current {buySellRatio >= 0.5
|
||||
? 'text-[#00FC50]'
|
||||
: 'text-[#EE5365]'} "
|
||||
stroke-width="3"
|
||||
stroke-dasharray="100"
|
||||
stroke-dashoffset={100 - buySellRatio * 100 >= 0
|
||||
? 100 - (buySellRatio * 100)?.toFixed(2)
|
||||
: 0}
|
||||
></circle>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Percentage Text -->
|
||||
<div
|
||||
class="absolute top-1/2 start-1/2 transform -translate-y-1/2 -translate-x-1/2"
|
||||
>
|
||||
<span
|
||||
class="text-center text-white text-sm sm:text-[1rem]"
|
||||
>{buySellRatio?.toFixed(2)}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Circular Progress -->
|
||||
</div>
|
||||
<!--End Buy/Sell-->
|
||||
<!--Start Dem/Rep-->
|
||||
<div
|
||||
class="flex flex-row items-center flex-wrap w-full px-3 sm:px-4 border border-gray-600 rounded-md h-20"
|
||||
>
|
||||
<div class="flex flex-col items-start">
|
||||
<span
|
||||
class="font-semibold text-white text-sm sm:text-[1rem]"
|
||||
>Dem/Rep</span
|
||||
>
|
||||
<span
|
||||
class="text-start text-sm sm:text-[1rem] font-medium text-white"
|
||||
>
|
||||
{partyRatio?.toFixed(3)}
|
||||
</span>
|
||||
</div>
|
||||
<!-- Circular Progress -->
|
||||
<div class="relative size-14 ml-auto">
|
||||
<svg
|
||||
class="size-full w-14 h-14"
|
||||
viewBox="0 0 36 36"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<!-- Background Circle -->
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current text-[#3E3E3E]"
|
||||
stroke-width="3"
|
||||
></circle>
|
||||
<!-- Progress Circle inside a group with rotation -->
|
||||
<g class="origin-center -rotate-90 transform">
|
||||
<circle
|
||||
cx="18"
|
||||
cy="18"
|
||||
r="16"
|
||||
fill="none"
|
||||
class="stroke-current text-blue-500"
|
||||
stroke-width="3"
|
||||
stroke-dasharray="100"
|
||||
stroke-dashoffset={100 - partyRatio * 100 >= 0
|
||||
? 100 - (partyRatio * 100)?.toFixed(2)
|
||||
: 0}
|
||||
></circle>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Percentage Text -->
|
||||
<div
|
||||
class="absolute top-1/2 start-1/2 transform -translate-y-1/2 -translate-x-1/2"
|
||||
>
|
||||
<span
|
||||
class="text-center text-white text-sm sm:text-[1rem]"
|
||||
>{partyRatio?.toFixed(2)}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Circular Progress -->
|
||||
</div>
|
||||
<!--End Put/Call-->
|
||||
</div>
|
||||
</div>
|
||||
<!--End Widget-->
|
||||
|
||||
<div
|
||||
class="mt-6 flex justify-start items-center w-full m-auto rounded-none sm:rounded-lg mb-4 overflow-x-scroll"
|
||||
>
|
||||
<table
|
||||
class="table table-sm sm:table-md table-compact rounded-none sm:rounded-md w-full bg-[#09090B] border-bg-[#09090B] m-auto"
|
||||
>
|
||||
<thead>
|
||||
<tr class="bg-[#09090B] border-b border-[#27272A]">
|
||||
<th
|
||||
class="shadow-md text-start bg-[#09090B] text-white text-sm font-semibold"
|
||||
>
|
||||
Person
|
||||
</th>
|
||||
<th
|
||||
class="shadow-md text-end bg-[#09090B] text-white text-sm font-semibold"
|
||||
>
|
||||
Transaction Date
|
||||
</th>
|
||||
<th
|
||||
class="shadow-md text-end bg-[#09090B] text-white text-sm font-semibold"
|
||||
>
|
||||
Amount
|
||||
</th>
|
||||
<th
|
||||
class="shadow-md text-white font-semibold text-end text-sm"
|
||||
>Type</th
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each senateTradingList as item}
|
||||
<tr
|
||||
class="odd:bg-[#27272A] sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] bg-[#09090B] border-b-[#09090B]"
|
||||
>
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] whitespace-nowrap pb-3 border-b border-b-[#09090B]"
|
||||
>
|
||||
<div class="flex flex-row items-center">
|
||||
<div
|
||||
class="flex-shrink-0 rounded-full border border-slate-700 w-9 h-9 relative {item?.party ===
|
||||
'Republican'
|
||||
? 'bg-[#98272B]'
|
||||
: item?.party === 'Democratic'
|
||||
? 'bg-[#295AC7]'
|
||||
: 'bg-[#4E2153]'} flex items-center justify-center"
|
||||
>
|
||||
<img
|
||||
style="clip-path: circle(50%);"
|
||||
class="rounded-full w-7"
|
||||
src={`${cloudFrontUrl}/assets/senator/${item?.representative?.replace(/\s+/g, "_")}.png`}
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col ml-3 font-normal">
|
||||
<a
|
||||
href={`/politicians/${item?.id}`}
|
||||
class="sm:hover:text-white text-blue-400"
|
||||
>{getAbbreviatedName(
|
||||
item?.representative?.replace("_", " "),
|
||||
)}</a
|
||||
>
|
||||
<span class="text-gray-300">{item?.party}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!--{item?.firstName} {item?.lastName}-->
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-b-[#09090B]"
|
||||
>
|
||||
{new Date(item?.transactionDate)?.toLocaleString(
|
||||
"en-US",
|
||||
{
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
daySuffix: "2-digit",
|
||||
},
|
||||
)}
|
||||
</td>
|
||||
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-b-[#09090B]"
|
||||
>
|
||||
{item?.amount}
|
||||
</td>
|
||||
<td
|
||||
class="text-end text-sm sm:text-[1rem] whitespace-nowrap text-white border-b border-b-[#09090B]"
|
||||
>
|
||||
{#if item?.type === "Bought"}
|
||||
<span class="text-[#00FC50]">Bought</span>
|
||||
{:else if item?.type === "Sold"}
|
||||
<span class="text-[#FF2F1F]">Sold</span>
|
||||
{:else if item?.type === "Exchange"}
|
||||
<span class="text-[#C6A755]">Exchange</span>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{#if rawData?.length >= 20}
|
||||
<label
|
||||
on:click={backToTop}
|
||||
class="w-32 py-1.5 mt-10 hover:bg-white hover:bg-opacity-[0.05] cursor-pointer m-auto flex justify-center items-center border border-slate-800 rounded-full"
|
||||
>
|
||||
Back to top
|
||||
</label>
|
||||
{/if}
|
||||
{:else}
|
||||
<h2
|
||||
class="pl-4 pr-4 flex justify-center items-center text-md sm:text-lg text-center text-slate-200"
|
||||
>
|
||||
No trading history available for {$displayCompanyName}. Likely
|
||||
no corrupt politican has interest in this stock.
|
||||
</h2>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="flex justify-center items-center h-80">
|
||||
<div class="relative">
|
||||
<label
|
||||
class="bg-[#09090B] rounded-xl h-14 w-14 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
|
||||
>
|
||||
<span class="loading loading-spinner loading-md text-gray-400"
|
||||
></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
80
src/routes/etf/[tickerID]/options/+layout.svelte
Normal file
80
src/routes/etf/[tickerID]/options/+layout.svelte
Normal file
@ -0,0 +1,80 @@
|
||||
<script lang="ts">
|
||||
import ArrowLogo from "lucide-svelte/icons/move-up-right";
|
||||
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<section class="w-full overflow-hidden min-h-screen">
|
||||
<div class="w-full overflow-hidden m-auto">
|
||||
<div class="sm:p-0 flex justify-center w-full m-auto overflow-hidden">
|
||||
<div
|
||||
class="relative flex justify-center items-start overflow-hidden w-full"
|
||||
>
|
||||
<main class="w-full lg:w-3/4">
|
||||
<slot />
|
||||
</main>
|
||||
|
||||
<aside class="hidden lg:block relative fixed w-1/4 ml-4">
|
||||
{#if data?.user?.tier !== "Pro" || data?.user?.freeTrial}
|
||||
<div
|
||||
class="w-full border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
|
||||
>
|
||||
<a
|
||||
href="/pricing"
|
||||
class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"
|
||||
>
|
||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||
Pro Subscription
|
||||
</h2>
|
||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0" />
|
||||
</div>
|
||||
<span class="text-white p-3 ml-3 mr-3">
|
||||
Upgrade now for unlimited access to all data and tools.
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div
|
||||
class="w-full border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
|
||||
>
|
||||
<a
|
||||
href={"/options-flow"}
|
||||
class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"
|
||||
>
|
||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||
Options Flow
|
||||
</h2>
|
||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0" />
|
||||
</div>
|
||||
<span class="text-white p-3 ml-3 mr-3">
|
||||
Get realtime options flow and customize your screener
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="w-full border border-gray-600 rounded-md h-fit pb-4 mt-4 cursor-pointer"
|
||||
>
|
||||
<a
|
||||
href={"/stock-screener"}
|
||||
class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0"
|
||||
>
|
||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||
Stock Screener
|
||||
</h2>
|
||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0" />
|
||||
</div>
|
||||
<span class="text-white p-3 ml-3 mr-3">
|
||||
Build your Stock Screener to find profitable stocks.
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@ -3,7 +3,7 @@
|
||||
numberOfUnreadNotification,
|
||||
displayCompanyName,
|
||||
screenWidth,
|
||||
stockTicker,
|
||||
etfTicker,
|
||||
setCache,
|
||||
getCache,
|
||||
} from "$lib/store";
|
||||
@ -474,7 +474,7 @@
|
||||
isLoaded = false;
|
||||
optionDetailsDesktopModal?.showModal();
|
||||
|
||||
rawDataHistory = await getDailyTransactions($stockTicker + "-" + date);
|
||||
rawDataHistory = await getDailyTransactions($etfTicker + "-" + date);
|
||||
|
||||
rawDataHistory?.forEach((item) => {
|
||||
item.dte = daysLeft(item?.date_expiration);
|
||||
@ -538,21 +538,21 @@
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>
|
||||
{$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""}
|
||||
{$displayCompanyName} ({$stockTicker}) Options Activity · stocknear
|
||||
{$displayCompanyName} ({$etfTicker}) Options Activity · stocknear
|
||||
</title>
|
||||
<meta
|
||||
name="description"
|
||||
content={`Detailed informaton of unusual options activity for ${$displayCompanyName} (${$stockTicker}).`}
|
||||
content={`Detailed informaton of unusual options activity for ${$displayCompanyName} (${$etfTicker}).`}
|
||||
/>
|
||||
|
||||
<!-- Other meta tags -->
|
||||
<meta
|
||||
property="og:title"
|
||||
content={`${$displayCompanyName} (${$stockTicker}) Options Activity · stocknear`}
|
||||
content={`${$displayCompanyName} (${$etfTicker}) Options Activity · stocknear`}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={`Detailed informaton of unusual options activity for ${$displayCompanyName} (${$stockTicker}).`}
|
||||
content={`Detailed informaton of unusual options activity for ${$displayCompanyName} (${$etfTicker}).`}
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
<!-- Add more Open Graph meta tags as needed -->
|
||||
@ -561,11 +561,11 @@
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta
|
||||
name="twitter:title"
|
||||
content={`${$displayCompanyName} (${$stockTicker}) Options Activity · stocknear`}
|
||||
content={`${$displayCompanyName} (${$etfTicker}) Options Activity · stocknear`}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:description"
|
||||
content={`Detailed informaton of unusual options activity for ${$displayCompanyName} (${$stockTicker}).`}
|
||||
content={`Detailed informaton of unusual options activity for ${$displayCompanyName} (${$etfTicker}).`}
|
||||
/>
|
||||
<!-- Add more Twitter meta tags as needed -->
|
||||
</svelte:head>
|
||||
@ -877,7 +877,7 @@
|
||||
<tr
|
||||
on:click={() => handleViewData(item?.date)}
|
||||
on:mouseover={() =>
|
||||
getDailyTransactions($stockTicker + "+" + item?.date)}
|
||||
getDailyTransactions($etfTicker + "+" + item?.date)}
|
||||
class="cursor-pointer sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] {index +
|
||||
1 ===
|
||||
optionList?.slice(0, 3)?.length &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user