/** * 백테스팅 — 투자분석 상세 레포트 (출력·PDF 저장용 팝업) */ import React, { useCallback, useEffect, useRef } from 'react'; import { createPortal } from 'react-dom'; import type { BacktestAnalysis, BacktestSignal } from '../../utils/backendApi'; import { BacktestDashboard } from '../BacktestResultModal'; import { printReportDocument } from '../../utils/printReportDocument'; import '../../styles/backtestReportPrint.css'; export interface BacktestAnalysisReportModel { analysis: BacktestAnalysis; signals: BacktestSignal[]; strategyName: string; symbol: string; symbolKo?: string; timeframe: string; barCount: number; createdAt?: string; reportKind: 'backtest' | 'live'; } interface Props { open: boolean; onClose: () => void; model: BacktestAnalysisReportModel | null; } const IcReport = () => ( ); const IcPrint = () => ( ); export default function BacktestAnalysisReportModal({ open, onClose, model }: Props) { const printAreaRef = useRef(null); useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [open, onClose]); const handlePrint = useCallback(() => { const root = printAreaRef.current; if (!root) return; printReportDocument( root.innerHTML, `GoldenChart 투자분석 레포트${model?.symbolKo ? ` · ${model.symbolKo}` : ''}`, ); }, [model?.symbolKo]); if (!open || !model) return null; const printedAt = new Date().toLocaleString('ko-KR', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', }); const content = ( { if (e.target === e.currentTarget) onClose(); }} > 투자분석 상세 레포트 {model.reportKind === 'live' ? '실시간 매매' : '백테스팅'} {model.symbolKo ? ` · ${model.symbolKo}` : ''} 인쇄 / PDF PDF 저장 시 대상에서 「PDF로 저장」 선택 · 색상 유지는 「배경 그래픽」 체크 닫기 GoldenChart 투자분석 레포트 출력일시 {printedAt} {model.createdAt ? ` · 분석 실행 ${model.createdAt}` : ''} {model.symbolKo && ( {model.symbolKo} )} ); return createPortal(content, document.body); }
{model.reportKind === 'live' ? '실시간 매매' : '백테스팅'} {model.symbolKo ? ` · ${model.symbolKo}` : ''}
PDF 저장 시 대상에서 「PDF로 저장」 선택 · 색상 유지는 「배경 그래픽」 체크
출력일시 {printedAt} {model.createdAt ? ` · 분석 실행 ${model.createdAt}` : ''}
{model.symbolKo}