import React from 'react'; import type { PriceStats } from '../utils/calculations'; interface StatsPanelProps { stats: PriceStats | null; symbol: string; onClose: () => void; } function fmt(n: number, digits = 2): string { if (!isFinite(n)) return '—'; return n.toLocaleString('en-US', { minimumFractionDigits: digits, maximumFractionDigits: digits }); } function fmtVol(n: number): string { if (n >= 1e9) return (n / 1e9).toFixed(2) + 'B'; if (n >= 1e6) return (n / 1e6).toFixed(2) + 'M'; if (n >= 1e3) return (n / 1e3).toFixed(2) + 'K'; return n.toFixed(0); } const StatRow: React.FC<{ label: string; value: string; highlight?: 'up' | 'down' | 'neutral' }> = ({ label, value, highlight }) => (
{label} {value}
); const StatsPanel: React.FC = ({ stats, symbol, onClose }) => { if (!stats) return null; const trendColor = stats.trend === 'up' ? 'up' : stats.trend === 'down' ? 'down' : 'neutral'; const changeColor = stats.change >= 0 ? 'up' : 'down'; return (
📊 {symbol} 통계
가격
= 0 ? '+' : ''}${fmt(stats.change)} (${fmt(stats.changePct)}%)`} highlight={changeColor} />
추세 & 강도
70 ? 'down' : stats.rrsi14 < 30 ? 'up' : 'neutral'} />
피벗 포인트
거래량
); }; export default StatsPanel;