diff --git a/tools/build_continuous_evaluation_dashboard_v1.py b/tools/build_continuous_evaluation_dashboard_v1.py index f7651df..877c025 100644 --- a/tools/build_continuous_evaluation_dashboard_v1.py +++ b/tools/build_continuous_evaluation_dashboard_v1.py @@ -156,6 +156,61 @@ def main() -> int: } save_json(args.out, result) + # ── Excel 파일 기입 (GatherTradingData.xlsx > evaluation_dashboard) ── + try: + import openpyxl + xlsx_path = ROOT / "GatherTradingData.xlsx" + if xlsx_path.exists(): + wb = openpyxl.load_workbook(xlsx_path) + sheet_name = "evaluation_dashboard" + + # 기존 시트 클리어 및 재생성 + if sheet_name in wb.sheetnames: + ws = wb[sheet_name] + ws.delete_rows(1, ws.max_row + 10) + else: + ws = wb.create_sheet(sheet_name) + + # 1. SUMMARY 섹션 기입 + ws.append(["Metric", "Value"]) + summary_metrics = [ + ("Generated At", result["generated_at"]), + ("Gate Status", result["gate"]), + ("Expectancy Pct", result["expectancy_pct"]), + ("Win Rate Pct", result["win_rate_pct"]), + ("Max Drawdown Pct", result["max_drawdown_pct"]), + ("Total Live Evaluated T+20", result["total_live_evaluated_t20"]), + ("Total Live Pending", result["total_live_pending"]), + ("Replay Record Count", result["replay_informational"]["replay_record_count"]), + ("Sufficient For Metrics", result["data_confidence"]["sufficient_for_metrics"]), + ("Min Required", result["data_confidence"]["min_required"]), + ("Current Live T+20", result["data_confidence"]["current_live_t20"]), + ("Gap", result["data_confidence"]["gap"]), + ("Estimated Ready", result["data_confidence"]["estimated_ready"]) + ] + for m, v in summary_metrics: + ws.append([m, v]) + + # 2. WEEKLY SCORECARD 섹션 기입 (오른쪽 열인 D열부터 시작) + ws.cell(row=1, column=4, value="Week") + ws.cell(row=1, column=5, value="Expectancy_Pct") + ws.cell(row=1, column=6, value="Win_Rate_Pct") + ws.cell(row=1, column=7, value="Max_Drawdown_Pct") + ws.cell(row=1, column=8, value="Trade_Count") + + for idx, w in enumerate(weekly_scorecard): + r_num = idx + 2 + ws.cell(row=r_num, column=4, value=w.get("week")) + ws.cell(row=r_num, column=5, value=w.get("expectancy_pct")) + ws.cell(row=r_num, column=6, value=w.get("win_rate_pct")) + ws.cell(row=r_num, column=7, value=w.get("max_drawdown_pct")) + ws.cell(row=r_num, column=8, value=w.get("trade_count")) + + wb.save(xlsx_path) + print(f"[EVALUATION_DASHBOARD] Saved evaluation_dashboard sheet to {xlsx_path.name}") + except Exception as e: + print(f"[EVALUATION_DASHBOARD][ERROR] Failed to save Excel sheet: {e}") + suffix = f"(need {max(0, MIN_T20_FOR_METRICS - live_t20_count)} more LIVE T+20)" if insufficient else "" print( f"[CONTINUOUS_EVALUATION_DASHBOARD_V1] gate={gate} "