From d3080f1e6e1beddccb8c619862604d39b726cab6 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Tue, 31 Dec 2024 12:45:08 +0100 Subject: [PATCH] update fail to deliver page --- src/lib/components/FailToDeliver.svelte | 103 ++++----- .../etf/[tickerID]/options/+layout.svelte | 2 +- .../etf/[tickerID]/options/+page.server.ts | 163 ++++++++++++- .../etf/[tickerID]/options/+page.svelte | 217 ++++++++---------- src/routes/list/bitcoin-etfs/+page.svelte | 6 +- src/routes/list/country/[slug]/+page.svelte | 6 +- src/routes/list/exchange/[slug]/+page.svelte | 6 +- src/routes/list/faang/+page.svelte | 6 +- src/routes/list/index/[slug]/+page.svelte | 6 +- src/routes/list/industry/[slug]/+page.svelte | 6 +- .../list/magnificent-seven/+page.svelte | 6 +- .../list/market-cap/[slug]/+page.svelte | 6 +- src/routes/list/sector/[slug]/+page.svelte | 6 +- .../[tickerID]/statistics/+layout.svelte | 12 + .../fail-to-deliver/+layout.server.ts | 28 +++ .../statistics/fail-to-deliver/+layout.svelte | 96 ++++++++ .../fail-to-deliver/+page.server.ts | 29 +++ .../statistics/fail-to-deliver/+page.svelte | 195 ++++++++++++++++ .../statistics/market-cap/+page.svelte | 42 +++- 19 files changed, 721 insertions(+), 220 deletions(-) create mode 100644 src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+layout.server.ts create mode 100644 src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+layout.svelte create mode 100644 src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.server.ts create mode 100644 src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.svelte diff --git a/src/lib/components/FailToDeliver.svelte b/src/lib/components/FailToDeliver.svelte index 2f39811d..02a71e7b 100644 --- a/src/lib/components/FailToDeliver.svelte +++ b/src/lib/components/FailToDeliver.svelte @@ -1,13 +1,9 @@ + +
+
+
+
+
+ +
+ + +
+
+
+
diff --git a/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.server.ts b/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.server.ts new file mode 100644 index 00000000..9e5f902a --- /dev/null +++ b/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.server.ts @@ -0,0 +1,29 @@ +export const load = async ({ locals, params }) => { + const getData = async () => { + const { apiKey, apiURL } = locals; + const postData = { + ticker: params.tickerID, + }; + + // make the POST request to the endpoint + const response = await fetch(apiURL + "/fail-to-deliver", { + 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 { + getData: await getData(), + }; +}; diff --git a/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.svelte b/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.svelte new file mode 100644 index 00000000..940aa15f --- /dev/null +++ b/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+page.svelte @@ -0,0 +1,195 @@ + + + + + + + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} + {$displayCompanyName} ({$stockTicker}) Fail-to-Deliver Shares · Stocknear + + + + + + + + + + +
+
+
+ {#if isLoaded} +
+
+
+

+ Fail-to-Deliver (FTD) +

+
+ + {#if rawData?.length !== 0} +
+
+
+
+
+ FTD Shares +
+
+ {abbreviateNumber( + rawData?.slice(-1)?.at(0)?.failToDeliver, + false, + )} +
+
+
+
+
+
+ FTD / Avg Volume +
+
+ {data?.getStockQuote?.avgVolume > 0 + ? ( + (rawData?.slice(-1)?.at(0)?.failToDeliver / + data?.getStockQuote?.avgVolume) * + 100 + )?.toFixed(2) + "%" + : "n/a"} +
+
+
+
+
+
+ 1-Year Change +
+
+ {changePercentageYearAgo !== null + ? abbreviateNumber( + changePercentageYearAgo?.toFixed(2), + ) + "%" + : "n/a"} +
+
+
+
+ + +
+ {:else} +

+ No data available +

+ {/if} +
+
+ {:else} +
+
+ +
+
+ {/if} +
+
+
diff --git a/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte b/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte index 2f52f823..491fedab 100644 --- a/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte +++ b/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte @@ -318,15 +318,33 @@ color: "#fff", // Optional: Text color for better visibility }, formatter: function (params) { - const date = params[0].name; // Get the date from the x-axis value - const dateParts = date.split("-"); - const year = dateParts[0]; - const monthIndex = parseInt(dateParts[1]) - 1; - const day = dateParts[2]; - const formattedDate = `${monthNames[monthIndex]} ${day}, ${year}`; + // Get the timestamp from the first parameter + const timestamp = params[0].axisValue; - // Return the tooltip content - return `${formattedDate}
${abbreviateNumber(params[0].value)}`; + // Initialize result with timestamp + let result = timestamp + "
"; + + // Add each series data + params.forEach((param) => { + const marker = + ''; + result += + marker + + param.seriesName + + ": " + + abbreviateNumber(param.value, false, true) + + "
"; + }); + + return result; + }, + axisPointer: { + lineStyle: { + color: "#fff", + }, }, }, }; @@ -439,7 +457,7 @@ >
-
+
Market Cap
-
Category
+
+ Category +
@@ -474,7 +494,7 @@
-
+
1-Year Change