import { useMemo } from 'react';
import { useTradingMetricsHistory } from '../../api/tradingHooks';
import { Card, LoadingSpinner } from '../../components/ui';
import {
LineChart, Line, BarChart, Bar, AreaChart, Area,
XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid, Cell,
} from 'recharts';
const tooltipStyle = {
backgroundColor: '#1e293b',
border: '1px solid #334155',
borderRadius: 8,
};
export function PerformanceCharts() {
const { data: snapshots, isLoading } = useTradingMetricsHistory();
const chartData = useMemo(() => {
if (!snapshots) return [];
return snapshots.map((s) => ({
date: new Date(s.snapshot_date).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }),
portfolioValue: s.portfolio_value,
cumulativeReturn: (s.cumulative_return ?? 0) * 100,
dailyReturn: (s.daily_return ?? 0) * 100,
drawdown: (s.current_drawdown_pct ?? 0) * 100,
maxDrawdown: (s.max_drawdown ?? 0) * 100,
}));
}, [snapshots]);
if (isLoading) return No performance history available yet