add ytd to chart
This commit is contained in:
parent
d69a8dd4e6
commit
e4021c5213
@ -1009,6 +1009,21 @@ function convertNYTimeToLocalTime(nyTimeString) {
|
|||||||
return localFormattedTime;
|
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) {
|
export function getPartyForPoliticians(name) {
|
||||||
// Predefined list of senators and their parties
|
// Predefined list of senators and their parties
|
||||||
|
|||||||
@ -22,7 +22,11 @@
|
|||||||
import News from "$lib/components/News.svelte";
|
import News from "$lib/components/News.svelte";
|
||||||
import ETFSidecard from "$lib/components/ETFSidecard.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 data;
|
||||||
export let form;
|
export let form;
|
||||||
@ -31,7 +35,7 @@
|
|||||||
|
|
||||||
$: previousClose = data?.getStockQuote?.previousClose;
|
$: 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 config = null;
|
||||||
let output = null;
|
let output = null;
|
||||||
@ -337,6 +341,11 @@
|
|||||||
graphBaseClose = oneMonthPrice?.at(0)?.close;
|
graphBaseClose = oneMonthPrice?.at(0)?.close;
|
||||||
config = plotData(oneMonthPrice) || null;
|
config = plotData(oneMonthPrice) || null;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
currentDataRow = ytdPrice?.at(-1);
|
||||||
|
graphBaseClose = ytdPrice?.at(0)?.close;
|
||||||
|
config = plotData(ytdPrice) || null;
|
||||||
|
break;
|
||||||
|
|
||||||
case "6M":
|
case "6M":
|
||||||
currentDataRow = sixMonthPrice?.at(-1);
|
currentDataRow = sixMonthPrice?.at(-1);
|
||||||
@ -460,7 +469,17 @@
|
|||||||
lastValue = null;
|
lastValue = null;
|
||||||
}
|
}
|
||||||
break;
|
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":
|
case "6M":
|
||||||
displayData = "6M";
|
displayData = "6M";
|
||||||
await historicalPrice("six-months");
|
await historicalPrice("six-months");
|
||||||
@ -505,6 +524,7 @@
|
|||||||
let oneDayPrice = [];
|
let oneDayPrice = [];
|
||||||
let oneWeekPrice = [];
|
let oneWeekPrice = [];
|
||||||
let oneMonthPrice = [];
|
let oneMonthPrice = [];
|
||||||
|
let ytdPrice = [];
|
||||||
let sixMonthPrice = [];
|
let sixMonthPrice = [];
|
||||||
|
|
||||||
let oneYearPrice = [];
|
let oneYearPrice = [];
|
||||||
@ -520,6 +540,9 @@
|
|||||||
case "one-month":
|
case "one-month":
|
||||||
oneMonthPrice = cachedData;
|
oneMonthPrice = cachedData;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
ytdPrice = cachedData;
|
||||||
|
break;
|
||||||
case "six-months":
|
case "six-months":
|
||||||
sixMonthPrice = cachedData;
|
sixMonthPrice = cachedData;
|
||||||
break;
|
break;
|
||||||
@ -559,6 +582,9 @@
|
|||||||
case "one-month":
|
case "one-month":
|
||||||
oneMonthPrice = output;
|
oneMonthPrice = output;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
ytdPrice = output;
|
||||||
|
break;
|
||||||
case "six-months":
|
case "six-months":
|
||||||
sixMonthPrice = output;
|
sixMonthPrice = output;
|
||||||
break;
|
break;
|
||||||
@ -631,6 +657,7 @@
|
|||||||
"1D": oneDayPrice,
|
"1D": oneDayPrice,
|
||||||
"1W": oneWeekPrice,
|
"1W": oneWeekPrice,
|
||||||
"1M": oneMonthPrice,
|
"1M": oneMonthPrice,
|
||||||
|
ytd: ytdPrice,
|
||||||
"6M": sixMonthPrice,
|
"6M": sixMonthPrice,
|
||||||
"1Y": oneYearPrice,
|
"1Y": oneYearPrice,
|
||||||
MAX: maxPrice,
|
MAX: maxPrice,
|
||||||
@ -649,6 +676,7 @@
|
|||||||
oneDayPrice = [];
|
oneDayPrice = [];
|
||||||
oneWeekPrice = [];
|
oneWeekPrice = [];
|
||||||
oneMonthPrice = [];
|
oneMonthPrice = [];
|
||||||
|
ytdPrice = [];
|
||||||
oneYearPrice = [];
|
oneYearPrice = [];
|
||||||
maxPrice = [];
|
maxPrice = [];
|
||||||
output = null;
|
output = null;
|
||||||
@ -687,15 +715,17 @@
|
|||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
on:click={() => changeData(interval)}
|
on:click={() => changeData(interval)}
|
||||||
class="cursor-pointer focus:outline-none"
|
class="cursor-pointer"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="block px-3 py-1 rounded duration-100 ease-in-out
|
class="block px-3 sm:px-2 py-1 text-sm sm:text-[1rem] rounded duration-100 ease-in-out
|
||||||
{displayData === interval
|
{displayData === interval
|
||||||
? 'bg-blue-50 text-blue-700 dark:bg-primary dark:text-white font-semibold'
|
? 'bg-gray-100 text-muted dark:bg-primary dark:text-white font-semibold'
|
||||||
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover:text-white sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
|
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover:text-white sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
|
||||||
>
|
>
|
||||||
{interval}
|
{$screenWidth < 640
|
||||||
|
? interval
|
||||||
|
: convertPeriodString(interval)}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -19,7 +19,11 @@
|
|||||||
import News from "$lib/components/News.svelte";
|
import News from "$lib/components/News.svelte";
|
||||||
import IndexSidecard from "$lib/components/IndexSidecard.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";
|
import { mode } from "mode-watcher";
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
@ -29,7 +33,7 @@
|
|||||||
|
|
||||||
$: previousClose = data?.getStockQuote?.previousClose;
|
$: 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 config = null;
|
||||||
let output = null;
|
let output = null;
|
||||||
@ -336,6 +340,11 @@
|
|||||||
graphBaseClose = oneMonthPrice?.at(0)?.close;
|
graphBaseClose = oneMonthPrice?.at(0)?.close;
|
||||||
config = plotData(oneMonthPrice) || null;
|
config = plotData(oneMonthPrice) || null;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
currentDataRow = ytdPrice?.at(-1);
|
||||||
|
graphBaseClose = ytdPrice?.at(0)?.close;
|
||||||
|
config = plotData(ytdPrice) || null;
|
||||||
|
break;
|
||||||
|
|
||||||
case "6M":
|
case "6M":
|
||||||
currentDataRow = sixMonthPrice?.at(-1);
|
currentDataRow = sixMonthPrice?.at(-1);
|
||||||
@ -459,7 +468,17 @@
|
|||||||
lastValue = null;
|
lastValue = null;
|
||||||
}
|
}
|
||||||
break;
|
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":
|
case "6M":
|
||||||
displayData = "6M";
|
displayData = "6M";
|
||||||
await historicalPrice("six-months");
|
await historicalPrice("six-months");
|
||||||
@ -504,6 +523,7 @@
|
|||||||
let oneDayPrice = [];
|
let oneDayPrice = [];
|
||||||
let oneWeekPrice = [];
|
let oneWeekPrice = [];
|
||||||
let oneMonthPrice = [];
|
let oneMonthPrice = [];
|
||||||
|
let ytdPrice = [];
|
||||||
let sixMonthPrice = [];
|
let sixMonthPrice = [];
|
||||||
|
|
||||||
let oneYearPrice = [];
|
let oneYearPrice = [];
|
||||||
@ -519,6 +539,9 @@
|
|||||||
case "one-month":
|
case "one-month":
|
||||||
oneMonthPrice = cachedData;
|
oneMonthPrice = cachedData;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
ytdPrice = cachedData;
|
||||||
|
break;
|
||||||
case "six-months":
|
case "six-months":
|
||||||
sixMonthPrice = cachedData;
|
sixMonthPrice = cachedData;
|
||||||
break;
|
break;
|
||||||
@ -558,6 +581,9 @@
|
|||||||
case "one-month":
|
case "one-month":
|
||||||
oneMonthPrice = output;
|
oneMonthPrice = output;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
ytdPrice = output;
|
||||||
|
break;
|
||||||
case "six-months":
|
case "six-months":
|
||||||
sixMonthPrice = output;
|
sixMonthPrice = output;
|
||||||
break;
|
break;
|
||||||
@ -630,6 +656,7 @@
|
|||||||
"1D": oneDayPrice,
|
"1D": oneDayPrice,
|
||||||
"1W": oneWeekPrice,
|
"1W": oneWeekPrice,
|
||||||
"1M": oneMonthPrice,
|
"1M": oneMonthPrice,
|
||||||
|
ytd: ytdPrice,
|
||||||
"6M": sixMonthPrice,
|
"6M": sixMonthPrice,
|
||||||
"1Y": oneYearPrice,
|
"1Y": oneYearPrice,
|
||||||
MAX: maxPrice,
|
MAX: maxPrice,
|
||||||
@ -648,6 +675,7 @@
|
|||||||
oneDayPrice = [];
|
oneDayPrice = [];
|
||||||
oneWeekPrice = [];
|
oneWeekPrice = [];
|
||||||
oneMonthPrice = [];
|
oneMonthPrice = [];
|
||||||
|
ytdPrice = [];
|
||||||
oneYearPrice = [];
|
oneYearPrice = [];
|
||||||
maxPrice = [];
|
maxPrice = [];
|
||||||
output = null;
|
output = null;
|
||||||
@ -701,15 +729,17 @@
|
|||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
on:click={() => changeData(interval)}
|
on:click={() => changeData(interval)}
|
||||||
class="cursor-pointer focus:outline-none"
|
class="cursor-pointer"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="block px-3 py-1 rounded duration-100 ease-in-out
|
class="block px-3 sm:px-2 py-1 text-sm sm:text-[1rem] rounded duration-100 ease-in-out
|
||||||
{displayData === interval
|
{displayData === interval
|
||||||
? 'bg-gray-200 text-muted dark:bg-primary dark: font-semibold'
|
? 'bg-gray-100 text-muted dark:bg-primary dark:text-white font-semibold'
|
||||||
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover: sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
|
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover:text-white sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
|
||||||
>
|
>
|
||||||
{interval}
|
{$screenWidth < 640
|
||||||
|
? interval
|
||||||
|
: convertPeriodString(interval)}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -1131,6 +1131,7 @@
|
|||||||
<span class="">Realtime Dark Pool Trades</span>
|
<span class="">Realtime Dark Pool Trades</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<!--
|
||||||
{#if !["Pro", "Plus"]?.includes(data?.user?.tier) || data?.user?.freeTrial === true}
|
{#if !["Pro", "Plus"]?.includes(data?.user?.tier) || data?.user?.freeTrial === true}
|
||||||
<div class="mt-3 items-center text-[1rem] font-medium mb-5">
|
<div class="mt-3 items-center text-[1rem] font-medium mb-5">
|
||||||
Promo Code: <strong>SPRINGSALE</strong>
|
Promo Code: <strong>SPRINGSALE</strong>
|
||||||
@ -1138,6 +1139,7 @@
|
|||||||
Get <strong>50% OFF</strong> on Pro Annual Membership!
|
Get <strong>50% OFF</strong> on Pro Annual Membership!
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
-->
|
||||||
<div class="mt-auto pt-6 border-t border-zinc-700 mx-4">
|
<div class="mt-auto pt-6 border-t border-zinc-700 mx-4">
|
||||||
<label
|
<label
|
||||||
for={!data?.user ? "userLogin" : ""}
|
for={!data?.user ? "userLogin" : ""}
|
||||||
|
|||||||
@ -24,7 +24,11 @@
|
|||||||
import EarningsSurprise from "$lib/components/EarningsSurprise.svelte";
|
import EarningsSurprise from "$lib/components/EarningsSurprise.svelte";
|
||||||
import Sidecard from "$lib/components/Sidecard.svelte";
|
import Sidecard from "$lib/components/Sidecard.svelte";
|
||||||
|
|
||||||
import { convertTimestamp, abbreviateNumber } from "$lib/utils";
|
import {
|
||||||
|
convertTimestamp,
|
||||||
|
abbreviateNumber,
|
||||||
|
convertPeriodString,
|
||||||
|
} from "$lib/utils";
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let form;
|
export let form;
|
||||||
@ -33,7 +37,7 @@
|
|||||||
|
|
||||||
$: previousClose = data?.getStockQuote?.previousClose;
|
$: 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 config = null;
|
||||||
let output = null;
|
let output = null;
|
||||||
@ -340,7 +344,11 @@
|
|||||||
graphBaseClose = oneMonthPrice?.at(0)?.close;
|
graphBaseClose = oneMonthPrice?.at(0)?.close;
|
||||||
config = plotData(oneMonthPrice) || null;
|
config = plotData(oneMonthPrice) || null;
|
||||||
break;
|
break;
|
||||||
|
case "YTD":
|
||||||
|
currentDataRow = ytdPrice?.at(-1);
|
||||||
|
graphBaseClose = ytdPrice?.at(0)?.close;
|
||||||
|
config = plotData(ytdPrice) || null;
|
||||||
|
break;
|
||||||
case "6M":
|
case "6M":
|
||||||
currentDataRow = sixMonthPrice?.at(-1);
|
currentDataRow = sixMonthPrice?.at(-1);
|
||||||
graphBaseClose = sixMonthPrice?.at(0)?.close;
|
graphBaseClose = sixMonthPrice?.at(0)?.close;
|
||||||
@ -463,7 +471,17 @@
|
|||||||
lastValue = null;
|
lastValue = null;
|
||||||
}
|
}
|
||||||
break;
|
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":
|
case "6M":
|
||||||
displayData = "6M";
|
displayData = "6M";
|
||||||
await historicalPrice("six-months");
|
await historicalPrice("six-months");
|
||||||
@ -508,6 +526,7 @@
|
|||||||
let oneDayPrice = [];
|
let oneDayPrice = [];
|
||||||
let oneWeekPrice = [];
|
let oneWeekPrice = [];
|
||||||
let oneMonthPrice = [];
|
let oneMonthPrice = [];
|
||||||
|
let ytdPrice = [];
|
||||||
let sixMonthPrice = [];
|
let sixMonthPrice = [];
|
||||||
|
|
||||||
let oneYearPrice = [];
|
let oneYearPrice = [];
|
||||||
@ -523,6 +542,9 @@
|
|||||||
case "one-month":
|
case "one-month":
|
||||||
oneMonthPrice = cachedData;
|
oneMonthPrice = cachedData;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
ytdPrice = cachedData;
|
||||||
|
break;
|
||||||
case "six-months":
|
case "six-months":
|
||||||
sixMonthPrice = cachedData;
|
sixMonthPrice = cachedData;
|
||||||
break;
|
break;
|
||||||
@ -562,6 +584,9 @@
|
|||||||
case "one-month":
|
case "one-month":
|
||||||
oneMonthPrice = output;
|
oneMonthPrice = output;
|
||||||
break;
|
break;
|
||||||
|
case "ytd":
|
||||||
|
ytdPrice = output;
|
||||||
|
break;
|
||||||
case "six-months":
|
case "six-months":
|
||||||
sixMonthPrice = output;
|
sixMonthPrice = output;
|
||||||
break;
|
break;
|
||||||
@ -634,6 +659,7 @@
|
|||||||
"1D": oneDayPrice,
|
"1D": oneDayPrice,
|
||||||
"1W": oneWeekPrice,
|
"1W": oneWeekPrice,
|
||||||
"1M": oneMonthPrice,
|
"1M": oneMonthPrice,
|
||||||
|
ytd: ytdPrice,
|
||||||
"6M": sixMonthPrice,
|
"6M": sixMonthPrice,
|
||||||
"1Y": oneYearPrice,
|
"1Y": oneYearPrice,
|
||||||
MAX: maxPrice,
|
MAX: maxPrice,
|
||||||
@ -652,6 +678,7 @@
|
|||||||
oneDayPrice = [];
|
oneDayPrice = [];
|
||||||
oneWeekPrice = [];
|
oneWeekPrice = [];
|
||||||
oneMonthPrice = [];
|
oneMonthPrice = [];
|
||||||
|
ytdPrice = [];
|
||||||
oneYearPrice = [];
|
oneYearPrice = [];
|
||||||
maxPrice = [];
|
maxPrice = [];
|
||||||
output = null;
|
output = null;
|
||||||
@ -694,15 +721,17 @@
|
|||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
on:click={() => changeData(interval)}
|
on:click={() => changeData(interval)}
|
||||||
class="cursor-pointer focus:outline-none"
|
class="cursor-pointer"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="block px-3 py-1 rounded duration-100 ease-in-out
|
class="block px-3 sm:px-2 py-1 text-sm sm:text-[1rem] rounded duration-100 ease-in-out
|
||||||
{displayData === interval
|
{displayData === interval
|
||||||
? 'bg-gray-200 text-muted dark:bg-primary dark:text-white font-semibold'
|
? 'bg-gray-100 text-muted dark:bg-primary dark:text-white font-semibold'
|
||||||
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover:text-white sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
|
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover:text-white sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
|
||||||
>
|
>
|
||||||
{interval}
|
{$screenWidth < 640
|
||||||
|
? interval
|
||||||
|
: convertPeriodString(interval)}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user