feat: add BELO peak hour analysis chart

- New backend endpoint GET /quotes/:type/peak-hours
- Groups daily price data by hour to find peak frequency
- Bar chart showing how often each hour is the daily peak
- Only displayed for BELO currency in analysis page
This commit is contained in:
Jose Selesan
2026-08-28 12:05:43 -03:00
parent 2fe8198c41
commit 0998d64cbb
6 changed files with 339 additions and 0 deletions

View File

@@ -45,6 +45,19 @@ export type HistoricalMinMax = {
maxBuyDate: string | null;
};
export type PeakHour = {
hour: number;
frequency: number;
avgPeakBuy: number;
minPeakBuy: number;
maxPeakBuy: number;
};
export type PeakHoursResponse = {
totalDays: number;
peaks: PeakHour[];
};
async function fetcher<T>(url: string): Promise<T> {
const res = await fetch(url, { credentials: "include" });
if (!res.ok) {
@@ -109,6 +122,15 @@ export function getHistoricalMinMax(type: string): Promise<HistoricalMinMax> {
return fetcher<HistoricalMinMax>(`/api/quotes/${type}/historical/min-max`);
}
export function getPeakHours(
type: string,
startDate: string,
endDate: string,
): Promise<PeakHoursResponse> {
const params = new URLSearchParams({ startDate, endDate });
return fetcher<PeakHoursResponse>(`/api/quotes/${type}/peak-hours?${params}`);
}
export type MonthlyLast = {
month: string;
type: "BELO" | "BLUE" | "BNA";