diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 8a557397..e50d23b9 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -1009,6 +1009,21 @@ function convertNYTimeToLocalTime(nyTimeString) {
return localFormattedTime;
}
*/
+export function convertPeriodString(interval) {
+ const mapping = {
+ "1D": "1 Day",
+ "1W": "5 Days", // Assuming "1W" means a trading week (5 days)
+ "1M": "1 Month",
+ "YTD": "YTD",
+ "3M": "3 Months",
+ "6M": "6 Months",
+ "1Y": "1 Year",
+ "5Y": "5 Years",
+ "MAX": "Max",
+ };
+
+ return mapping[interval] || interval; // Return original if no match
+}
export function getPartyForPoliticians(name) {
// Predefined list of senators and their parties
diff --git a/src/routes/etf/[tickerID]/+page.svelte b/src/routes/etf/[tickerID]/+page.svelte
index 3b81e95a..bbb4a54b 100644
--- a/src/routes/etf/[tickerID]/+page.svelte
+++ b/src/routes/etf/[tickerID]/+page.svelte
@@ -22,7 +22,11 @@
import News from "$lib/components/News.svelte";
import ETFSidecard from "$lib/components/ETFSidecard.svelte";
- import { convertTimestamp, abbreviateNumber } from "$lib/utils";
+ import {
+ convertTimestamp,
+ abbreviateNumber,
+ convertPeriodString,
+ } from "$lib/utils";
export let data;
export let form;
@@ -31,7 +35,7 @@
$: previousClose = data?.getStockQuote?.previousClose;
//============================================//
- const intervals = ["1D", "1W", "1M", "6M", "1Y", "MAX"];
+ const intervals = ["1D", "1W", "1M", "YTD", "6M", "1Y", "MAX"];
let config = null;
let output = null;
@@ -337,6 +341,11 @@
graphBaseClose = oneMonthPrice?.at(0)?.close;
config = plotData(oneMonthPrice) || null;
break;
+ case "ytd":
+ currentDataRow = ytdPrice?.at(-1);
+ graphBaseClose = ytdPrice?.at(0)?.close;
+ config = plotData(ytdPrice) || null;
+ break;
case "6M":
currentDataRow = sixMonthPrice?.at(-1);
@@ -460,7 +469,17 @@
lastValue = null;
}
break;
-
+ case "ytd":
+ displayData = "ytd";
+ await historicalPrice("ytd");
+ if (ytdPrice?.length !== 0) {
+ displayLastLogicalRangeValue = ytdPrice?.at(0)?.close;
+ lastValue = ytdPrice.slice(-1)?.at(0)?.close;
+ } else {
+ displayLastLogicalRangeValue = null;
+ lastValue = null;
+ }
+ break;
case "6M":
displayData = "6M";
await historicalPrice("six-months");
@@ -505,6 +524,7 @@
let oneDayPrice = [];
let oneWeekPrice = [];
let oneMonthPrice = [];
+ let ytdPrice = [];
let sixMonthPrice = [];
let oneYearPrice = [];
@@ -520,6 +540,9 @@
case "one-month":
oneMonthPrice = cachedData;
break;
+ case "ytd":
+ ytdPrice = cachedData;
+ break;
case "six-months":
sixMonthPrice = cachedData;
break;
@@ -559,6 +582,9 @@
case "one-month":
oneMonthPrice = output;
break;
+ case "ytd":
+ ytdPrice = output;
+ break;
case "six-months":
sixMonthPrice = output;
break;
@@ -631,6 +657,7 @@
"1D": oneDayPrice,
"1W": oneWeekPrice,
"1M": oneMonthPrice,
+ ytd: ytdPrice,
"6M": sixMonthPrice,
"1Y": oneYearPrice,
MAX: maxPrice,
@@ -649,6 +676,7 @@
oneDayPrice = [];
oneWeekPrice = [];
oneMonthPrice = [];
+ ytdPrice = [];
oneYearPrice = [];
maxPrice = [];
output = null;
@@ -687,15 +715,17 @@
diff --git a/src/routes/index/[tickerID]/+page.svelte b/src/routes/index/[tickerID]/+page.svelte
index cd073b63..45734be0 100644
--- a/src/routes/index/[tickerID]/+page.svelte
+++ b/src/routes/index/[tickerID]/+page.svelte
@@ -19,7 +19,11 @@
import News from "$lib/components/News.svelte";
import IndexSidecard from "$lib/components/IndexSidecard.svelte";
- import { convertTimestamp, abbreviateNumber } from "$lib/utils";
+ import {
+ convertTimestamp,
+ abbreviateNumber,
+ convertPeriodString,
+ } from "$lib/utils";
import { mode } from "mode-watcher";
export let data;
@@ -29,7 +33,7 @@
$: previousClose = data?.getStockQuote?.previousClose;
//============================================//
- const intervals = ["1D", "1W", "1M", "6M", "1Y", "MAX"];
+ const intervals = ["1D", "1W", "1M", "YTD", "6M", "1Y", "MAX"];
let config = null;
let output = null;
@@ -336,6 +340,11 @@
graphBaseClose = oneMonthPrice?.at(0)?.close;
config = plotData(oneMonthPrice) || null;
break;
+ case "ytd":
+ currentDataRow = ytdPrice?.at(-1);
+ graphBaseClose = ytdPrice?.at(0)?.close;
+ config = plotData(ytdPrice) || null;
+ break;
case "6M":
currentDataRow = sixMonthPrice?.at(-1);
@@ -459,7 +468,17 @@
lastValue = null;
}
break;
-
+ case "ytd":
+ displayData = "ytd";
+ await historicalPrice("ytd");
+ if (ytdPrice?.length !== 0) {
+ displayLastLogicalRangeValue = ytdPrice?.at(0)?.close;
+ lastValue = ytdPrice.slice(-1)?.at(0)?.close;
+ } else {
+ displayLastLogicalRangeValue = null;
+ lastValue = null;
+ }
+ break;
case "6M":
displayData = "6M";
await historicalPrice("six-months");
@@ -504,6 +523,7 @@
let oneDayPrice = [];
let oneWeekPrice = [];
let oneMonthPrice = [];
+ let ytdPrice = [];
let sixMonthPrice = [];
let oneYearPrice = [];
@@ -519,6 +539,9 @@
case "one-month":
oneMonthPrice = cachedData;
break;
+ case "ytd":
+ ytdPrice = cachedData;
+ break;
case "six-months":
sixMonthPrice = cachedData;
break;
@@ -558,6 +581,9 @@
case "one-month":
oneMonthPrice = output;
break;
+ case "ytd":
+ ytdPrice = output;
+ break;
case "six-months":
sixMonthPrice = output;
break;
@@ -630,6 +656,7 @@
"1D": oneDayPrice,
"1W": oneWeekPrice,
"1M": oneMonthPrice,
+ ytd: ytdPrice,
"6M": sixMonthPrice,
"1Y": oneYearPrice,
MAX: maxPrice,
@@ -648,6 +675,7 @@
oneDayPrice = [];
oneWeekPrice = [];
oneMonthPrice = [];
+ ytdPrice = [];
oneYearPrice = [];
maxPrice = [];
output = null;
@@ -701,15 +729,17 @@
diff --git a/src/routes/pricing/+page.svelte b/src/routes/pricing/+page.svelte
index 7f22cda6..2e91c907 100644
--- a/src/routes/pricing/+page.svelte
+++ b/src/routes/pricing/+page.svelte
@@ -1131,6 +1131,7 @@
Realtime Dark Pool Trades
+