From f370caeff90f4968821a27c44712af78b6a77e7f Mon Sep 17 00:00:00 2001 From: aszerW Date: Sun, 7 Jun 2026 22:43:12 +0800 Subject: [PATCH] feat: add HTML report screenshot generation via Playwright - Add html_report.py module for Playwright-based screenshot generation - Add generate_html_report() method to SimpleRotationStrategy - Modify backtest_viewer.html to use window-scoped variables for external injection - Inject monthly/yearly returns table into screenshot - Auto-generate HTML report in __main__ after export_results() Output: simple_rotation_html_report.png with ranking table + monthly returns --- .gitignore | 6 + rotation/backtest_viewer.html | 14 +- rotation/html_report.py | 285 ++++++++++++++++++++++++++++++++++ rotation/simple_rotation.py | 32 ++++ 4 files changed, 332 insertions(+), 5 deletions(-) create mode 100644 rotation/html_report.py diff --git a/.gitignore b/.gitignore index 4ba6711..eb17b4a 100644 --- a/.gitignore +++ b/.gitignore @@ -199,3 +199,9 @@ zhihu-articles/ # Results directory (test outputs, charts, etc.) results/ + +# Node.js (local testing only) +node_modules/ +package.json +package-lock.json +rotation/test_screenshot.mjs diff --git a/rotation/backtest_viewer.html b/rotation/backtest_viewer.html index a7a77e3..6a9bd88 100644 --- a/rotation/backtest_viewer.html +++ b/rotation/backtest_viewer.html @@ -152,11 +152,15 @@ tr.below-threshold { color: #484f58; }