Skip to content

Commit 9d1f947

Browse files
author
Tonny@Home
committed
doc: merge and back test feature for rolling train
1 parent 802a245 commit 9d1f947

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

docs/30_ROLLING_TRAINING_GUIDE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@ python quantpits/scripts/rolling_train.py --cold-start --all-enabled
9898
# 指定模型
9999
python quantpits/scripts/rolling_train.py --cold-start --models linear_Alpha158
100100
101+
# 追加新模型 (Merge Mode)
102+
python quantpits/scripts/rolling_train.py --merge --models new_model_A
103+
101104
# Dry-run: 仅查看窗口划分
102105
python quantpits/scripts/rolling_train.py --cold-start --dry-run --all-enabled
103106
```
104107

108+
冷启动扩展功能:
109+
- `--merge`:在已有的一批训练结果之上追加新的模型。已经训练完毕的模型将不再重复训练,仅针对新加入的模型执行全窗口的冷启动,完成后统一合并 `pred.pkl`
110+
- `--backtest`:附加此参数,在所有窗口训练预测合并完成后,将自动执行一次针对整体时间的完整 Qlib 回测,生成包含收益率报告与仓位数据的标准化产物。
111+
105112
冷启动流程:
106113
1.`rolling_config.yaml` 读取参数
107114
2. 生成所有 rolling windows(到 anchor_date 为止)
@@ -127,6 +134,16 @@ python quantpits/scripts/rolling_train.py --all-enabled
127134
python quantpits/scripts/rolling_train.py --predict-only --all-enabled
128135
```
129136

137+
### 模式四:单独回测评估
138+
139+
如果之前已经运行过冷启动或合并流程,且 `latest_rolling_records.json` 存在预测记录,但缺失回测报告(或希望使用新配置重新回测),可以使用独立回测模式。此模式将跳过所有的训练和预测环节,直接使用历史拼接好的全局预测分 (`pred.pkl`) 执行完整的 Qlib 回测。
140+
141+
```bash
142+
python quantpits/scripts/rolling_train.py --backtest-only
143+
```
144+
145+
生成的标准化产物 (`report_normal_<freq>.pkl`, `positions_normal_<freq>.pkl` 等) 以及 indicator 分析指标将保存在 MLflow 的 Combined 实验记录下。
146+
130147
### 断点恢复
131148

132149
训练中断时,自动跳过已完成的 window × model:

docs/en/30_ROLLING_TRAINING_GUIDE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@ python quantpits/scripts/rolling_train.py --cold-start --all-enabled
9898
# Specify models
9999
python quantpits/scripts/rolling_train.py --cold-start --models linear_Alpha158
100100
101+
# Append new models (Merge Mode)
102+
python quantpits/scripts/rolling_train.py --merge --models new_model_A
103+
101104
# Dry-run: preview window slicing only
102105
python quantpits/scripts/rolling_train.py --cold-start --dry-run --all-enabled
103106
```
104107

108+
Cold Start Add-on Features:
109+
- `--merge`: Append new models to an existing cold-started state. Already-trained models will not be re-trained. It performs window training only for the newly added models, then merges their global predictions (`pred.pkl`) with existing ones.
110+
- `--backtest`: Append this flag to automatically execute a complete Qlib backtest over the aggregate time frame after all training, predicting, and merging finishes. Standardized backtest artifacts (returns reports, positions) will be saved.
111+
105112
Cold start workflow:
106113
1. Read parameters from `rolling_config.yaml`
107114
2. Generate all rolling windows (up to anchor_date)
@@ -127,6 +134,16 @@ Use the most recently trained window's model to predict on new data:
127134
python quantpits/scripts/rolling_train.py --predict-only --all-enabled
128135
```
129136

137+
### Mode 4: Standalone Backtest Evaluation
138+
139+
If a run was previously executed and `latest_rolling_records.json` exists with concatenated predictions, but the comprehensive backtest was skipped (or is desired to be rerun with updated configs), you can use the standalone backtest mode. This mode skips all machine learning training and prediction steps. It directly runs a full Qlib Backtest simulation using the stored concatenated prediction scores (`pred.pkl`).
140+
141+
```bash
142+
python quantpits/scripts/rolling_train.py --backtest-only
143+
```
144+
145+
Standardized artifacts (`report_normal_<freq>.pkl`, `positions_normal_<freq>.pkl`, etc.) and indicator summaries will be stored under the designated comprehensive MLflow record.
146+
130147
### Crash Recovery
131148

132149
After interruption, automatically skips completed window × model pairs:

0 commit comments

Comments
 (0)