bugfixing
This commit is contained in:
parent
25cd8c693a
commit
af67492e11
@ -173,6 +173,8 @@
|
||||
|
||||
let tableForecastRevenue = [];
|
||||
let tableForecastEPS = [];
|
||||
let tableCombinedRevenue = [];
|
||||
let tableCombinedEPS = [];
|
||||
|
||||
function getPlotOptions(dataType: string) {
|
||||
let dates = [];
|
||||
@ -534,6 +536,8 @@
|
||||
function prepareData() {
|
||||
tableActualRevenue = [];
|
||||
tableForecastRevenue = [];
|
||||
tableCombinedRevenue = [];
|
||||
tableCombinedEPS = [];
|
||||
|
||||
tableActualEPS = [];
|
||||
tableForecastEPS = [];
|
||||
@ -558,6 +562,20 @@
|
||||
});
|
||||
});
|
||||
|
||||
tableCombinedRevenue = tableActualRevenue?.map((item1) => {
|
||||
// Find the corresponding item in data2 based on "FY"
|
||||
const item2 = tableForecastRevenue?.find(
|
||||
(item2) => item2?.FY === item1?.FY,
|
||||
);
|
||||
|
||||
// If the value in data1 is null, replace it with the value from data2
|
||||
return {
|
||||
FY: item1.FY,
|
||||
val: item1.val === null ? item2.val : item1.val,
|
||||
numOfAnalysts: item2.numOfAnalysts,
|
||||
};
|
||||
});
|
||||
|
||||
//EPS Data
|
||||
filteredData?.forEach((item) => {
|
||||
tableActualEPS?.push({
|
||||
@ -572,10 +590,21 @@
|
||||
//Values coincide with table values for crosscheck
|
||||
revenueAvgGrowthList = computeGrowthList(
|
||||
tableActualRevenue,
|
||||
tableForecastRevenue,
|
||||
tableCombinedRevenue,
|
||||
);
|
||||
|
||||
epsAvgGrowthList = computeGrowthList(tableActualEPS, tableForecastEPS);
|
||||
tableCombinedEPS = tableActualEPS?.map((item1) => {
|
||||
// Find the corresponding item in data2 based on "FY"
|
||||
const item2 = tableForecastEPS?.find((item2) => item2?.FY === item1?.FY);
|
||||
|
||||
// If the value in data1 is null, replace it with the value from data2
|
||||
return {
|
||||
FY: item1.FY,
|
||||
val: item1.val === null ? item2.val : item1.val,
|
||||
};
|
||||
});
|
||||
|
||||
epsAvgGrowthList = computeGrowthList(tableActualEPS, tableCombinedEPS);
|
||||
}
|
||||
|
||||
$: {
|
||||
@ -630,7 +659,7 @@
|
||||
>
|
||||
Revenue
|
||||
</th>
|
||||
{#each tableForecastRevenue as item}
|
||||
{#each tableCombinedRevenue as item}
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] text-end font-medium border-b border-[#27272A] bg-[#09090B]"
|
||||
>
|
||||
@ -649,7 +678,7 @@
|
||||
>
|
||||
Revenue Growth
|
||||
</th>
|
||||
{#each computeGrowthList(tableActualRevenue, tableForecastRevenue) as item, index}
|
||||
{#each computeGrowthList(tableActualRevenue, tableCombinedRevenue) as item, index}
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] text-end font-medium bg-[#09090B]"
|
||||
>
|
||||
@ -684,7 +713,7 @@
|
||||
>
|
||||
EPS
|
||||
</th>
|
||||
{#each tableForecastEPS as item}
|
||||
{#each tableCombinedEPS as item}
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] text-end font-medium border-b border-[#27272A] bg-[#09090B]"
|
||||
>
|
||||
@ -703,7 +732,7 @@
|
||||
>
|
||||
EPS Growth
|
||||
</th>
|
||||
{#each computeGrowthList(tableActualEPS, tableForecastEPS) as item, index}
|
||||
{#each computeGrowthList(tableActualEPS, tableCombinedEPS) as item, index}
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] text-end font-medium bg-[#09090B]"
|
||||
>
|
||||
@ -756,13 +785,17 @@
|
||||
class="text-white whitespace-nowrap text-sm sm:text-[1rem] text-start font-medium bg-[#27272A] border-b border-[#27272A]"
|
||||
>No. Analysts</th
|
||||
>
|
||||
{#each tableForecastRevenue as item}
|
||||
{#each tableCombinedRevenue as item}
|
||||
<td
|
||||
class="text-white text-sm sm:text-[1rem] text-end font-medium border-b border-[#27272A] bg-[#09090B]"
|
||||
>
|
||||
{#if item?.FY > 24}
|
||||
{item?.numOfAnalysts === (null || 0)
|
||||
? "n/a"
|
||||
: item?.numOfAnalysts}
|
||||
{:else}
|
||||
-
|
||||
{/if}
|
||||
</td>
|
||||
{/each}
|
||||
</tr>
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
import { isOpen } from "$lib/store";
|
||||
|
||||
const checkMarketHour = async () => {
|
||||
const holidays = [
|
||||
"2024-01-01",
|
||||
"2024-01-15",
|
||||
"2024-02-19",
|
||||
"2024-03-29",
|
||||
"2024-05-27",
|
||||
"2024-06-19",
|
||||
"2024-07-04",
|
||||
"2024-09-02",
|
||||
"2024-11-28",
|
||||
"2024-12-25",
|
||||
];
|
||||
const currentDate = new Date().toISOString().split("T")[0];
|
||||
|
||||
// Get the current time in the ET time zone
|
||||
const etTimeZone = "America/New_York";
|
||||
const currentTime = new Date().toLocaleString("en-US", {
|
||||
timeZone: etTimeZone,
|
||||
});
|
||||
|
||||
// Determine if the NYSE is currently open or closed
|
||||
const currentHour = new Date(currentTime).getHours();
|
||||
const isWeekendValue =
|
||||
new Date(currentTime).getDay() === 6 ||
|
||||
new Date(currentTime).getDay() === 0;
|
||||
const isBeforeMarketOpenValue =
|
||||
currentHour < 9 ||
|
||||
(currentHour === 9 && new Date(currentTime).getMinutes() < 30);
|
||||
const isAfterMarketCloseValue = currentHour >= 16;
|
||||
|
||||
isOpen.set(
|
||||
!(
|
||||
isWeekendValue ||
|
||||
isBeforeMarketOpenValue ||
|
||||
isAfterMarketCloseValue ||
|
||||
holidays?.includes(currentDate)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
export const load = async () => {
|
||||
await checkMarketHour();
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user