bugfixing
This commit is contained in:
parent
d3a6d608f5
commit
b3228fb1ca
@ -1644,18 +1644,7 @@ export const monthNames = [
|
|||||||
"Dec",
|
"Dec",
|
||||||
];
|
];
|
||||||
|
|
||||||
export const holidays = [
|
export const holidays = ['2025-01-01', '2025-01-09','2025-01-20', '2025-02-17', '2025-04-18', '2025-05-26', '2025-06-19', '2025-07-04', '2025-09-01', '2025-11-27', '2025-12-25']
|
||||||
"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",
|
|
||||||
];
|
|
||||||
|
|
||||||
export const getLastTradingDay = () => {
|
export const getLastTradingDay = () => {
|
||||||
const etTimeZone = "America/New_York";
|
const etTimeZone = "America/New_York";
|
||||||
|
|||||||
@ -52,24 +52,30 @@
|
|||||||
const categories = ["Strong Buy", "Buy", "Hold", "Sell", "Strong Sell"];
|
const categories = ["Strong Buy", "Buy", "Hold", "Sell", "Strong Sell"];
|
||||||
|
|
||||||
function findIndex(data) {
|
function findIndex(data) {
|
||||||
const currentYear = new Date().getFullYear();
|
let year = new Date().getFullYear() - 1;
|
||||||
|
|
||||||
// Find the index where the item's date is greater than the current year and revenue is null
|
while (year > 0) {
|
||||||
const index = data?.findIndex(
|
// Ensure we don't loop indefinitely
|
||||||
(item) => item?.date > currentYear && item?.revenue === null,
|
// Find the index where the item's date matches the current year and revenue is null
|
||||||
);
|
const index = data?.findIndex(
|
||||||
|
(item) => item?.date === year && item?.revenue === null,
|
||||||
// If index is found and there is at least one item in the data for the current year with non-null revenue
|
|
||||||
if (index !== -1) {
|
|
||||||
const hasNonNullRevenue = data?.some(
|
|
||||||
(item) => item?.date === currentYear && item?.revenue !== null,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add +1 to the index if the condition is met
|
// If index is found and there is at least one item in the data for this year with non-null revenue
|
||||||
return hasNonNullRevenue ? index + 1 : index;
|
if (index !== -1) {
|
||||||
|
const hasNonNullRevenue = data?.some(
|
||||||
|
(item) => item?.date === year && item?.revenue !== null,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add +1 to the index if the condition is met
|
||||||
|
return hasNonNullRevenue ? index + 1 : index;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decrement the year to search the previous year
|
||||||
|
year--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return index; // Return the index or -1 if not found
|
return -1; // Return -1 if no matching index is found
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTotalForDate(index) {
|
function getTotalForDate(index) {
|
||||||
@ -100,7 +106,7 @@
|
|||||||
const colors = ["#9E190A", "#D9220E", "#FF9E21", "#31B800", "#008A00"];
|
const colors = ["#9E190A", "#D9220E", "#FF9E21", "#31B800", "#008A00"];
|
||||||
|
|
||||||
// Create a consistent mapping for data
|
// Create a consistent mapping for data
|
||||||
const formattedData = rawAnalystList.map((item) =>
|
const formattedData = rawAnalystList?.map((item) =>
|
||||||
categories.map((cat) => item[cat] || 0),
|
categories.map((cat) => item[cat] || 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -262,16 +268,14 @@
|
|||||||
|
|
||||||
// Calculate changes using the helper function
|
// Calculate changes using the helper function
|
||||||
const estimatedRevenueAvg =
|
const estimatedRevenueAvg =
|
||||||
data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg;
|
|
||||||
const revenue = data?.getAnalystEstimate[index - 2]?.revenue;
|
|
||||||
const estimatedRevenueAvgNextYear =
|
|
||||||
data?.getAnalystEstimate[index]?.estimatedRevenueAvg;
|
data?.getAnalystEstimate[index]?.estimatedRevenueAvg;
|
||||||
|
const revenue = data?.getAnalystEstimate[index - 1]?.revenue;
|
||||||
const estimatedEpsAvg =
|
const estimatedRevenueAvgNextYear =
|
||||||
data?.getAnalystEstimate[index - 1]?.estimatedEpsAvg;
|
data?.getAnalystEstimate[index + 1]?.estimatedRevenueAvg;
|
||||||
const eps = data?.getAnalystEstimate[index - 2]?.eps;
|
const estimatedEpsAvg = data?.getAnalystEstimate[index]?.estimatedEpsAvg;
|
||||||
|
const eps = data?.getAnalystEstimate[index - 1]?.eps;
|
||||||
const estimatedEPSAvgNextYear =
|
const estimatedEPSAvgNextYear =
|
||||||
data?.getAnalystEstimate[index]?.estimatedEpsAvg;
|
data?.getAnalystEstimate[index + 1]?.estimatedEpsAvg;
|
||||||
|
|
||||||
// Calculate percentage changes for each metric
|
// Calculate percentage changes for each metric
|
||||||
changeRevenue = calculateChange(estimatedRevenueAvg, revenue);
|
changeRevenue = calculateChange(estimatedRevenueAvg, revenue);
|
||||||
@ -284,6 +288,8 @@
|
|||||||
estimatedEPSAvgNextYear,
|
estimatedEPSAvgNextYear,
|
||||||
estimatedEpsAvg,
|
estimatedEpsAvg,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(changeRevenue, revenue, estimatedRevenueAvg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPriceForecastChart() {
|
function getPriceForecastChart() {
|
||||||
@ -380,7 +386,7 @@
|
|||||||
{
|
{
|
||||||
name: "Historical",
|
name: "Historical",
|
||||||
type: "line",
|
type: "line",
|
||||||
data: processedHistorical.map((point) => [point.date, point.value]),
|
data: processedHistorical?.map((point) => [point.date, point.value]),
|
||||||
symbol: "circle",
|
symbol: "circle",
|
||||||
symbolSize: 6,
|
symbolSize: 6,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
@ -393,7 +399,7 @@
|
|||||||
{
|
{
|
||||||
name: "High",
|
name: "High",
|
||||||
type: "line",
|
type: "line",
|
||||||
data: forecastHigh.map((point) => [point.date, point.value]),
|
data: forecastHigh?.map((point) => [point.date, point.value]),
|
||||||
symbol: "none",
|
symbol: "none",
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
type: "dashed",
|
type: "dashed",
|
||||||
@ -403,7 +409,7 @@
|
|||||||
{
|
{
|
||||||
name: "Average",
|
name: "Average",
|
||||||
type: "line",
|
type: "line",
|
||||||
data: forecastAvg.map((point) => [point.date, point.value]),
|
data: forecastAvg?.map((point) => [point.date, point.value]),
|
||||||
symbol: "none",
|
symbol: "none",
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
type: "dashed",
|
type: "dashed",
|
||||||
@ -413,7 +419,7 @@
|
|||||||
{
|
{
|
||||||
name: "Low",
|
name: "Low",
|
||||||
type: "line",
|
type: "line",
|
||||||
data: forecastLow.map((point) => [point.date, point.value]),
|
data: forecastLow?.map((point) => [point.date, point.value]),
|
||||||
symbol: "none",
|
symbol: "none",
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
type: "dashed",
|
type: "dashed",
|
||||||
@ -741,26 +747,27 @@
|
|||||||
<div
|
<div
|
||||||
class="flex items-baseline text-2xl font-semibold text-white"
|
class="flex items-baseline text-2xl font-semibold text-white"
|
||||||
>
|
>
|
||||||
{data?.getAnalystEstimate[index - 1]
|
{data?.getAnalystEstimate[index]?.estimatedRevenueAvg !==
|
||||||
?.estimatedRevenueAvg !== null &&
|
null &&
|
||||||
data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg !==
|
data?.getAnalystEstimate[index]?.estimatedRevenueAvg !== 0
|
||||||
0
|
|
||||||
? abbreviateNumber(
|
? abbreviateNumber(
|
||||||
data?.getAnalystEstimate[index - 1]
|
data?.getAnalystEstimate[index]?.estimatedRevenueAvg,
|
||||||
?.estimatedRevenueAvg,
|
|
||||||
)
|
)
|
||||||
: "n/a"}
|
: "n/a"}
|
||||||
{#if data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg !== null && data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg !== 0}
|
{#if data?.getAnalystEstimate[index]?.estimatedRevenueAvg !== null && data?.getAnalystEstimate[index]?.estimatedRevenueAvg !== 0}
|
||||||
<div
|
<div
|
||||||
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
||||||
>
|
>
|
||||||
from {abbreviateNumber(
|
from {data?.getAnalystEstimate[index - 1]?.revenue !==
|
||||||
data?.getAnalystEstimate[index - 2]?.revenue,
|
undefined
|
||||||
)}
|
? abbreviateNumber(
|
||||||
|
data?.getAnalystEstimate[index - 1]?.revenue,
|
||||||
|
)
|
||||||
|
: "n/a"}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg !== null && data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg !== 0}
|
{#if data?.getAnalystEstimate[index]?.estimatedRevenueAvg !== null && data?.getAnalystEstimate[index]?.estimatedRevenueAvg !== 0}
|
||||||
<div
|
<div
|
||||||
class="inline-flex items-baseline rounded-full px-2.5 py-0.5 text-sm font-semibold md:mt-2 lg:mt-0 {changeRevenue >
|
class="inline-flex items-baseline rounded-full px-2.5 py-0.5 text-sm font-semibold md:mt-2 lg:mt-0 {changeRevenue >
|
||||||
0
|
0
|
||||||
@ -788,13 +795,15 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg !== null && data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg !== 0}
|
{#if data?.getAnalystEstimate[index]?.estimatedRevenueAvg !== null && data?.getAnalystEstimate[index]?.estimatedRevenueAvg !== 0}
|
||||||
<div
|
<div
|
||||||
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
||||||
>
|
>
|
||||||
from {abbreviateNumber(
|
from {data?.getAnalystEstimate[index - 1]?.revenue !== null
|
||||||
data?.getAnalystEstimate[index - 2]?.revenue,
|
? abbreviateNumber(
|
||||||
)}
|
data?.getAnalystEstimate[index - 1]?.revenue,
|
||||||
|
)
|
||||||
|
: "n/a"}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@ -810,16 +819,23 @@
|
|||||||
<div
|
<div
|
||||||
class="flex items-baseline text-2xl font-semibold text-white"
|
class="flex items-baseline text-2xl font-semibold text-white"
|
||||||
>
|
>
|
||||||
{abbreviateNumber(
|
{data?.getAnalystEstimate[index + 1]
|
||||||
data?.getAnalystEstimate[index]?.estimatedRevenueAvg,
|
?.estimatedRevenueAvg !== undefined
|
||||||
)}
|
? abbreviateNumber(
|
||||||
|
data?.getAnalystEstimate[index + 1]
|
||||||
|
?.estimatedRevenueAvg,
|
||||||
|
)
|
||||||
|
: "n/a"}
|
||||||
<div
|
<div
|
||||||
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
||||||
>
|
>
|
||||||
from {abbreviateNumber(
|
from {data?.getAnalystEstimate[index]
|
||||||
data?.getAnalystEstimate[index - 1]
|
?.estimatedRevenueAvg !== undefined
|
||||||
?.estimatedRevenueAvg,
|
? abbreviateNumber(
|
||||||
)}
|
data?.getAnalystEstimate[index]
|
||||||
|
?.estimatedRevenueAvg,
|
||||||
|
)
|
||||||
|
: "n/a"}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -851,9 +867,12 @@
|
|||||||
<div
|
<div
|
||||||
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
||||||
>
|
>
|
||||||
from {abbreviateNumber(
|
from {data?.getAnalystEstimate[index]?.estimatedRevenueAvg !==
|
||||||
data?.getAnalystEstimate[index - 1]?.estimatedRevenueAvg,
|
undefined
|
||||||
)}
|
? abbreviateNumber(
|
||||||
|
data?.getAnalystEstimate[index]?.estimatedRevenueAvg,
|
||||||
|
)
|
||||||
|
: "n/a"}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -869,12 +888,12 @@
|
|||||||
class="flex items-baseline text-2xl font-semibold text-white"
|
class="flex items-baseline text-2xl font-semibold text-white"
|
||||||
>
|
>
|
||||||
{abbreviateNumber(
|
{abbreviateNumber(
|
||||||
data?.getAnalystEstimate[index - 1]?.estimatedEpsAvg,
|
data?.getAnalystEstimate[index]?.estimatedEpsAvg,
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
||||||
>
|
>
|
||||||
from {data?.getAnalystEstimate[index - 2]?.eps}
|
from {data?.getAnalystEstimate[index - 1]?.eps}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -906,7 +925,7 @@
|
|||||||
<div
|
<div
|
||||||
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
||||||
>
|
>
|
||||||
from {data?.getAnalystEstimate[index - 2]?.eps}
|
from {data?.getAnalystEstimate[index - 1]?.eps}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -922,13 +941,13 @@
|
|||||||
class="flex items-baseline text-2xl font-semibold text-white"
|
class="flex items-baseline text-2xl font-semibold text-white"
|
||||||
>
|
>
|
||||||
{abbreviateNumber(
|
{abbreviateNumber(
|
||||||
data?.getAnalystEstimate[index]?.estimatedEpsAvg,
|
data?.getAnalystEstimate[index + 1]?.estimatedEpsAvg,
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
class="ml-2 block text-sm font-semibold text-white lg:hidden"
|
||||||
>
|
>
|
||||||
from {abbreviateNumber(
|
from {abbreviateNumber(
|
||||||
data?.getAnalystEstimate[index - 1]?.estimatedEpsAvg,
|
data?.getAnalystEstimate[index]?.estimatedEpsAvg,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -962,7 +981,7 @@
|
|||||||
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
class="ml-0.5 mt-1.5 hidden text-sm font-semibold text-white lg:block"
|
||||||
>
|
>
|
||||||
from {abbreviateNumber(
|
from {abbreviateNumber(
|
||||||
data?.getAnalystEstimate[index - 1]?.estimatedEpsAvg,
|
data?.getAnalystEstimate[index]?.estimatedEpsAvg,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user