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
This commit is contained in:
2026-06-07 22:43:12 +08:00
parent 06df8767b9
commit f370caeff9
4 changed files with 332 additions and 5 deletions

View File

@@ -152,11 +152,15 @@ tr.below-threshold { color: #484f58; }
</div>
<script>
let DATA = null;
let currentIdx = 0;
let playing = false;
let playTimer = null;
let rebalanceDays = [];
// Use window. to allow external access (for Playwright screenshot injection)
window.DATA = null;
window.currentIdx = 0;
window.playing = false;
window.playTimer = null;
window.rebalanceDays = [];
// Convenience aliases for script-internal use
const DATA_PROXY = { get data() { return window.DATA; }, set data(v) { window.DATA = v; } };
const $ = id => document.getElementById(id);