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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user