"use client"; import { useEffect, useState } from "react"; import { api, type MetricsResponse } from "../lib/api"; export function MetricsPanel({ code }: { code: string }) { const [m, setM] = useState(null); const [err, setErr] = useState(null); useEffect(() => { let alive = true; api .metrics(code, 30) .then((r) => { if (alive) setM(r); }) .catch((e) => { if (alive) setErr(e instanceof Error ? e.message : String(e)); }); return () => { alive = false; }; }, [code]); if (err) return
메트릭 로딩 실패: {err}
; if (!m) return
메트릭 로딩 중…
; const rows = m.by_model_horizon ?? []; if (!rows.length) { return (
최근 30일 매칭된 예측 결과가 아직 없습니다. (매칭 배치는 평일 16:30 KST 에 실행)
); } return (
최근 30일 모델 성능
{rows.map((r, i) => ( ))}
모델 +거래일 표본 수 방향 적중률 평균 절대오차 (MAE)
{r.model} +{r.horizon} {r.n} {r.hit_rate != null ? `${(r.hit_rate * 100).toFixed(1)}%` : "-"} {r.mae != null ? r.mae.toLocaleString(undefined, { maximumFractionDigits: 1 }) : "-"}
); }