feat: overlay stock price on trend charts with right Y axis

- New GET /api/market/prices/{ticker} endpoint serving OHLCV data from
  market_snapshots, deduped by bar_timestamp
- New useMarketPrices hook in frontend
- Trend chart now shows price (purple line) on a right Y axis ($)
  alongside trend metrics (%) on the left Y axis
- Custom tooltip formats price as dollars, metrics as percentages
- Price line uses connectNulls for days with missing bar data
This commit is contained in:
Celes Renata
2026-04-17 01:09:36 +00:00
parent ebe0ccca4c
commit c4206b3f4c
3 changed files with 133 additions and 15 deletions
+20
View File
@@ -245,6 +245,26 @@ export function useTrendHistory(params?: { ticker?: string; window?: string; lim
return useGet<TrendSummary[]>(['trend-history', params], 'query', path);
}
export interface MarketPrice {
ticker: string;
close: number;
open: number;
high: number;
low: number;
volume: number;
bar_timestamp: number;
captured_at: string;
}
export function useMarketPrices(ticker: string | undefined, limit = 30) {
return useGet<MarketPrice[]>(
['market-prices', ticker, limit],
'query',
`/api/market/prices/${ticker}?limit=${limit}`,
!!ticker,
);
}
export function useTrend(id: string | undefined) {
return useGet<TrendSummary>(['trend', id], 'query', `/api/trends/${id}`, !!id);
}