earnings update

This commit is contained in:
2024-03-08 01:44:40 -05:00
parent ac6e89720f
commit 31348ba105
5 changed files with 154 additions and 114 deletions
+1
View File
@@ -19,6 +19,7 @@
"@tanstack/react-table": "^8.13.2", "@tanstack/react-table": "^8.13.2",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.0", "clsx": "^2.1.0",
"date-fns": "^3.3.1",
"lightweight-charts": "^4.1.3", "lightweight-charts": "^4.1.3",
"lucide-react": "^0.338.0", "lucide-react": "^0.338.0",
"next": "14.1.0", "next": "14.1.0",
+7
View File
@@ -35,6 +35,9 @@ dependencies:
clsx: clsx:
specifier: ^2.1.0 specifier: ^2.1.0
version: 2.1.0 version: 2.1.0
date-fns:
specifier: ^3.3.1
version: 3.3.1
lightweight-charts: lightweight-charts:
specifier: ^4.1.3 specifier: ^4.1.3
version: 4.1.3 version: 4.1.3
@@ -1352,6 +1355,10 @@ packages:
resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}
dev: true dev: true
/[email protected]:
resolution: {integrity: sha512-y8e109LYGgoQDveiEBD3DYXKba1jWf5BA8YU1FL5Tvm0BTdEfy54WLCwnuYWZNnzzvALy/QQ4Hov+Q9RVRv+Zw==}
dev: false
/[email protected]: /[email protected]:
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
peerDependencies: peerDependencies:
+80 -68
View File
@@ -212,58 +212,58 @@ export const sampleDataTwo = [
{ time: "2019-03-18", value: 71.00787215611817 }, { time: "2019-03-18", value: 71.00787215611817 },
]; ];
export const earningsTable = [ // export const earningsTable = [
{ // {
ticker: "NVDA", // ticker: "NVDA",
date: "2024-04-23", // date: "2024-04-23",
time: "1600", // time: "1600",
}, // },
{ // {
ticker: "AAPL", // ticker: "AAPL",
date: "2024-04-23", // date: "2024-04-23",
time: "0400", // time: "0400",
}, // },
{ // {
ticker: "MSFT", // ticker: "MSFT",
date: "2024-04-23", // date: "2024-04-23",
time: "0400", // time: "0400",
}, // },
{ // {
ticker: "V", // ticker: "V",
date: "2024-04-24", // date: "2024-04-24",
time: "0400", // time: "0400",
}, // },
{ // {
ticker: "X", // ticker: "X",
date: "2024-04-24", // date: "2024-04-24",
time: "1600", // time: "1600",
}, // },
{ // {
ticker: "TSLA", // ticker: "TSLA",
date: "2024-04-25", // date: "2024-04-25",
time: "0400", // time: "0400",
}, // },
{ // {
ticker: "BRK", // ticker: "BRK",
date: "2024-04-25", // date: "2024-04-25",
time: "1600", // time: "1600",
}, // },
{ // {
ticker: "GOOG", // ticker: "GOOG",
date: "2024-04-26", // date: "2024-04-26",
time: "1600", // time: "1600",
}, // },
{ // {
ticker: "GNPX", // ticker: "GNPX",
date: "2024-04-27", // date: "2024-04-27",
time: "1600", // time: "1600",
}, // },
{ // {
ticker: "AMRN", // ticker: "AMRN",
date: "2024-04-28", // date: "2024-04-28",
time: "0400", // time: "0400",
}, // },
]; // ];
export const heatmapData = { export const heatmapData = {
"name": "nivo", "name": "nivo",
@@ -944,39 +944,51 @@ export const markets = [
]; ];
export const earningsCalendar = [ export const earningsCalendar = [
{ "value": 6, "day": "2024-02-24" },
{ "value": 0, "day": "2024-02-25" },
{ "value": 0, "day": "2024-02-26" },
{ "value": 9, "day": "2024-02-27" },
{ "value": 6, "day": "2024-02-28" },
{ "value": 3, "day": "2024-02-29" },
{ "value": 1, "day": "2024-03-01" },
{ "value": 9, "day": "2024-03-02" },
{ "value": 3, "day": "2024-03-03" },
{ "value": 0, "day": "2024-03-04" },
{ "value": 6, "day": "2024-03-05" },
{ "value": 3, "day": "2024-03-06" },
{ "value": 6, "day": "2024-03-07" }, { "value": 6, "day": "2024-03-07" },
{ "value": 4, "day": "2024-03-08" }, { "value": 4, "day": "2024-03-08" },
{ "value": 10, "day": "2024-03-09" }, { "value": 10, "day": "2024-03-09" },
{ "value": 8, "day": "2024-03-10" }, { "value": 0, "day": "2024-03-10" },
{ "value": 1, "day": "2024-03-11" }, { "value": 1, "day": "2024-03-11" },
{ "value": 0, "day": "2024-03-12" }, { "value": 0, "day": "2024-03-12" },
{ "value": 10, "day": "2024-03-13" }, { "value": 10, "day": "2024-03-13" },
{ "value": 9, "day": "2024-03-14" }, { "value": 9, "day": "2024-03-14" },
{ "value": 5, "day": "2024-03-15" }, { "value": 0, "day": "2024-03-15" },
{ "value": 6, "day": "2024-03-16" }, { "value": 6, "day": "2024-03-16" },
{ "value": 10, "day": "2024-03-17" }, { "value": 0, "day": "2024-03-17" },
{ "value": 1, "day": "2024-03-18" }, { "value": 0, "day": "2024-03-18" },
{ "value": 10, "day": "2024-03-19" }, { "value": 10, "day": "2024-03-19" },
{ "value": 2, "day": "2024-03-20" }, { "value": 2, "day": "2024-03-20" },
{ "value": 2, "day": "2024-03-21" }, { "value": 2, "day": "2024-03-21" },
{ "value": 4, "day": "2024-03-22" }, { "value": 4, "day": "2024-03-22" },
{ "value": 9, "day": "2024-03-23" }, { "value": 9, "day": "2024-03-23" },
{ "value": 10, "day": "2024-03-24" }, { "value": 0, "day": "2024-03-24" },
{ "value": 0, "day": "2024-03-25" }, { "value": 0, "day": "2024-03-25" },
{ "value": 10, "day": "2024-03-26" }, { "value": 10, "day": "2024-03-26" },
{ "value": 9, "day": "2024-03-27" }, { "value": 9, "day": "2024-03-27" },
{ "value": 2, "day": "2024-03-28" }, { "value": 2, "day": "2024-03-28" },
{ "value": 4, "day": "2024-03-29" }, { "value": 4, "day": "2024-03-29" },
{ "value": 3, "day": "2024-03-30" }, { "value": 3, "day": "2024-03-30" },
{ "value": 7, "day": "2024-03-31" }, { "value": 0, "day": "2024-03-31" },
{ "value": 1, "day": "2024-04-01" }, // { "value": 1, "day": "2024-04-01" },
{ "value": 6, "day": "2024-04-02" }, // { "value": 6, "day": "2024-04-02" },
{ "value": 5, "day": "2024-04-03" }, // { "value": 5, "day": "2024-04-03" },
{ "value": 6, "day": "2024-04-04" }, // { "value": 6, "day": "2024-04-04" },
{ "value": 6, "day": "2024-04-05" }, // { "value": 6, "day": "2024-04-05" },
{ "value": 7, "day": "2024-04-06" }, // { "value": 7, "day": "2024-04-06" },
{ "value": 7, "day": "2024-04-07" }, // { "value": 7, "day": "2024-04-07" },
{ "value": 2, "day": "2024-04-08" }, // { "value": 2, "day": "2024-04-08" },
{ "value": 7, "day": "2024-04-09" }, // { "value": 7, "day": "2024-04-09" },
{ "value": 1, "day": "2024-04-10" }, // { "value": 1, "day": "2024-04-10" },
]; ];
+57 -37
View File
@@ -1,45 +1,65 @@
import React from "react"; import React from "react";
import { ResponsiveTimeRange } from "@nivo/calendar"; import { ResponsiveTimeRange } from "@nivo/calendar";
import { earningsCalendar } from "@/app/MockData/MockData";
import {
compareAsc,
format,
lightFormat,
parse,
startOfWeek,
subDays,
} from "date-fns";
import { cn } from "@/lib/utils";
const CalendarSquares = ({ data }: any) => { interface earningsData {
const fromDate = new Date(); value: number;
const toDate = fromDate.getDate() + 30; day: string;
}
interface calendarSquaresProps {
data: earningsData[];
}
const CalendarSquares = ({ data }: calendarSquaresProps) => {
const today = new Date();
const thisWeek = startOfWeek(today);
const lastWeek = lightFormat(subDays(thisWeek, 6), "yyyy-MM-dd");
const calendar = data.filter(
(item: any) => compareAsc(item.day, lastWeek) >= 0
);
const values = calendar.map((obj) => obj.value);
const minValue = Math.min(...values);
const maxValue = Math.max(...values);
const valueRange = maxValue - minValue;
const lowBreakpoint = minValue + valueRange / 3;
const mediumBreakpoint = minValue + (2 * valueRange) / 3;
return ( return (
<ResponsiveTimeRange <div className="h-full grid grid-rows-4 grid-cols-7 xl:grid-rows-5 2xl:grid-rows-6 overflow-hidden text-neutral-900">
data={data} {calendar.map((item: any) => (
// from={fromDate.toLocaleString("en-us")} <div
// to={toDate.toLocaleDateString("en-us")} className={cn(
from="2024-03-07" compareAsc(item.day, today) < 0
to="2024-04-11" ? "bg-neutral-500 text-neutral-700"
emptyColor="#171717" : item.value < lowBreakpoint
colors={["#61cdbb", "#97e3d5", "#e8c1a0", "#f47560"]} ? "bg-[#fef7dc]/75"
margin={{ top: -70 }} : item.value < mediumBreakpoint
direction="vertical" ? "bg-[#fdedaa]/75"
square={false} : "bg-primary/75",
firstWeekday="thursday" "flex flex-col items-center justify-center font-bold hover:cursor-pointer"
weekdayTicks={[]} )}
tooltip={undefined} key={item.day}
// monthLegendOffset={0} >
weekdayLegendOffset={0} <div className={"text-xs"}>{format(item.day, "MMM")}</div>
dayBorderWidth={1} <div className="">{lightFormat(item.day, "d")}</div>
dayBorderColor="#ffffff" </div>
// legends={[ ))}
// { </div>
// anchor: "bottom-right",
// direction: "row",
// justify: false,
// itemCount: 4,
// itemWidth: 42,
// itemHeight: 36,
// itemsSpacing: 14,
// itemDirection: "right-to-left",
// translateX: -60,
// translateY: -60,
// symbolSize: 20,
// },
// ]}
/>
); );
}; };
+9 -9
View File
@@ -115,7 +115,7 @@ export const MoversModule = () => {
<div className="text-xs text-right text-neutral-400 2xl:w-20 2xl:text-base"> <div className="text-xs text-right text-neutral-400 2xl:w-20 2xl:text-base">
{item.stockPrice} {item.stockPrice}
</div> </div>
<div className="text-xs ml-2 rounded-lg bg-green-700 bg-opacity-90 w-20 text-center 2xl:ml-4 2xl:text-base"> <div className="text-xs ml-2 rounded-lg bg-green-500 bg-opacity-90 w-20 text-center 2xl:ml-4 2xl:text-base">
+{item.percentChange}% +{item.percentChange}%
</div> </div>
</div> </div>
@@ -134,7 +134,7 @@ export const MoversModule = () => {
<div className="text-xs text-right text-neutral-400 2xl:w-20 2xl:text-base"> <div className="text-xs text-right text-neutral-400 2xl:w-20 2xl:text-base">
{item.stockPrice} {item.stockPrice}
</div> </div>
<div className="text-xs ml-2 rounded-lg bg-red-700 bg-opacity-90 w-20 text-center 2xl:ml-4 2xl:text-base"> <div className="text-xs ml-2 rounded-lg bg-red-500 bg-opacity-90 w-20 text-center 2xl:ml-4 2xl:text-base">
{item.percentChange}% {item.percentChange}%
</div> </div>
</div> </div>
@@ -172,17 +172,17 @@ export const MarketsModule = () => {
return ( return (
<HomepageModule title="Markets"> <HomepageModule title="Markets">
<div className="flex h-full items-center py-4"> <div className="flex h-full items-center py-2 2xl:py-4">
<div className="flex flex-col justify-between w-2/5 h-full px-2"> <div className="flex flex-col justify-between h-full px-2">
{markets.map((marketItem) => ( {markets.map((marketItem) => (
<div <div
key={marketItem.symbol} key={marketItem.symbol}
className="rounded-lg hover:bg-neutral-700 hover:cursor-pointer" className="rounded-md hover:bg-neutral-700 hover:cursor-pointer"
> >
<div className="flex items-center pl-2 py-1 justify-between border-b border-neutral-700"> <div className="flex items-center pl-2 py-1 justify-between border-b border-neutral-700">
<div className="font-semibold">{marketItem.symbol}</div> <div className="text-sm font-semibold">{marketItem.symbol}</div>
<div className="flex justify-between space-x-4 text-sm pr-2"> <div className="flex justify-between space-x-4 text-sm pr-2">
<div className="w-12 text-right"> <div className="text-sm w-12 text-right 2xl:text-base">
{getLastPrice(marketItem.chart)} {getLastPrice(marketItem.chart)}
</div> </div>
<div <div
@@ -190,7 +190,7 @@ export const MarketsModule = () => {
getPriceDifference(marketItem.chart, 1) > 0 getPriceDifference(marketItem.chart, 1) > 0
? "text-green-500" ? "text-green-500"
: "text-red-500", : "text-red-500",
"w-12 text-right" "text-sm w-10 text-right 2xl:w-12 2xl:text-base"
)} )}
> >
{getPriceDifference(marketItem.chart, 1)} {getPriceDifference(marketItem.chart, 1)}
@@ -209,7 +209,7 @@ export const MarketsModule = () => {
</div> </div>
))} ))}
</div> </div>
<div className="h-full w-3/5 relative"> <div className="h-full grow relative">
<div className="absolute ml-4 mt-1">S&P 500</div> <div className="absolute ml-4 mt-1">S&P 500</div>
<Chart <Chart
series={[sp500IndexLine, sma5Line]} series={[sp500IndexLine, sma5Line]}