import { useMemo } from 'react'; import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import type { ProofOfYieldRecord, ProofOfYieldSummary } from '@/lib/analytics-api'; type Point = { ts: string; cumulative: number; pnl: number; }; type PerformanceLedgerProps = { summary: ProofOfYieldSummary; records: ProofOfYieldRecord[]; }; export function PerformanceLedger({ summary, records }: PerformanceLedgerProps) { const sorted = useMemo( () => [...records].sort((a, b) => new Date(a.settled_at).getTime() - new Date(b.settled_at).getTime()), [records], ); const curve: Point[] = useMemo(() => { let sum = 0; return sorted.map((record) => { sum += record.pnl; return { ts: record.settled_at.slice(0, 16).replace('T', ' '), cumulative: Number(sum.toFixed(4)), pnl: record.pnl, }; }); }, [sorted]); const maxClv = useMemo(() => { const values = records.map((record) => record.clv_percent).filter((value) => value !== null) as number[]; if (values.length === 0) { return 0; } return Math.max(...values); }, [records]); return (

推薦筆數

{summary.total_recommendations}

命中率

{summary.win_rate_percent.toFixed(1)}%

報酬率

= 10 ? 'text-[#d1432d]' : 'text-[#7d2a15]'}`}> {summary.roi_percent.toFixed(2)}%

平均收盤價差

{summary.avg_clv_percent.toFixed(2)}%

公開建議資金成長曲線

歷史最佳收盤價差:{maxClv.toFixed(2)}%

建議明細(公開透明)

{records.map((record) => ( ))} {records.length === 0 ? ( ) : null}
比賽 市場 選項 投入 推薦賠率 收盤賠率 收盤價差 結果 P/L
{record.match_id} {record.market_type} {record.selection} {record.stake} {record.recommended_odds} {record.closing_odds} {record.clv_percent === null ? '-' : `${record.clv_percent.toFixed(2)}%`} {record.is_win ? '命中' : '未中'} = 0 ? 'text-[#1a9a57]' : 'text-[#8c2f2f]'}`}> {record.pnl >= 0 ? '+' : ''}{record.pnl.toFixed(2)}
目前尚未有可公開核對的建議紀錄
); }