添加批量解析

This commit is contained in:
2026-07-11 03:22:50 +08:00
parent 9cdf93cc3d
commit 491ea17137
985 changed files with 4285 additions and 103 deletions
+39 -2
View File
@@ -12,6 +12,7 @@
|---|---|---|
| `mt5_report_parser.py` | 解析 MT5 中文 xlsx 报告(设置/结果/订单/成交),重建逐笔交易 | `MT5Report` 对象 |
| `run_analysis.py` | 主分析器:核心指标对比、What-If 假设、蒙特卡洛、方向/时段诊断、数据驱动建议 | `report.html` |
| `batch_report.py` | **新增** 大批量报告汇总:排名表 + 分布图 + 异常检测 | `batch_report.html` |
| `walk_forward.py` | Walk-Forward 滚动 IS→OOS 验证,算 WFE 与泛化相关性 | `walk_forward.html` |
| `param_scan.py` | 参数敏感度扫描:网格 .set 生成 → 响应面 → 高原检测 → **输出优化后 .set** | `param_scan.html` + `.set` |
| `mae_mfe.py` | MAE/MFE 分析:散点 + TP/SL 扫描热力图,附 MQL5 导出代码 | `mae_mfe.html` |
@@ -61,13 +62,15 @@ python mae_mfe.py mae_mfe_2026-06-28.csv
```
.
├── mt5_report_parser.py # 通用 MT5 xlsx 解析器
├── mt5_report_parser.py # 通用 MT5 xlsx 解析器(含 LRU 缓存 + 公共 _seg_metrics
├── run_analysis.py # 主分析器(含 What-If/蒙特卡洛/规则建议/Walk-Forward 集成)
├── walk_forward.py # Walk-Forward 滚动验证
├── batch_report.py # 新增:大批量报告汇总(排名 + 分布 + 异常检测)
├── walk_forward.py # Walk-Forward 滚动验证(向量化边界查找)
├── param_scan.py # 参数敏感度扫描 + 优化 .set 输出
├── mae_mfe.py # MAE/MFE 分析 + MQL5 代码片段
├── output/ # 生成产物(HTML/.set,已入库便于在线预览)
│ ├── report.html
│ ├── batch_report.html
│ ├── walk_forward.html
│ ├── param_scan.html
│ └── mae_mfe.html
@@ -76,6 +79,28 @@ python mae_mfe.py mae_mfe_2026-06-28.csv
└── METRICS_GUIDE.md # 指标说明书(大白话解释所有指标原理)
```
### 批量报告分析(新增)
扫描目录下所有 MT5 xlsx 报告,一次性汇总成排名表 + 指标分布 + 异常检测:
```bash
# 扫描目录下的所有 xlsx
python batch_report.py reports_dir
# 指定 glob 模式
python batch_report.py reports_dir --pattern "ReportTester-*.xlsx"
# 通配多目录
python batch_report.py "dir1/*.xlsx" "dir2/*.xlsx"
```
生成的 `output/batch_report.html` 包含:
- 按 PF 排名的综合表
- 按净盈利排名的综合表
- PF/净盈利/胜率分布直方图
- PF vs 胜率散点图(带趋势线)
- 异常检测:过拟合嫌疑 / 样本不足 / 回撤过大自动标记
## 各模块详解
### 1. mt5_report_parser.py — 解析器
@@ -178,6 +203,18 @@ MT5 标准 xlsx 不含逐笔 MAE/MFE。本模块提供:
无 matplotlib 等重型绘图库,所有可视化用纯 SVG。
## 性能优化
对大批量报告分析场景做的关键优化:
| 优化 | 位置 | 说明 |
|---|---|---|
| Monte Carlo 向量化 | `run_analysis.py` | 1000 次置换矩阵一次性生成,C 层完成随机打乱 |
| TP/SL 扫描向量化 | `mae_mfe.py` | 30×30×N 笔 → NumPy 广播,消除 Python 嵌套循环 |
| Walk-Forward 边界查找 | `walk_forward.py` | `np.searchsorted` 替代逐行 DataFrame 切片 |
| 解析结果缓存 | `mt5_report_parser.py` | 文件级 LRU 缓存,同一份报告被多模块复用时不再重复 IO |
| 公共指标函数 | `mt5_report_parser.py` | `_seg_metrics` / `_stats_from_net` 合并为 `compute_segment_metrics`,消除重复代码 |
## License
MIT