Skip to content

Commit 3d936e4

Browse files
Pigbibicodex
andcommitted
Add strategy lifecycle evidence gates
Co-Authored-By: Codex <noreply@openai.com>
1 parent cc1e09e commit 3d936e4

15 files changed

Lines changed: 831 additions & 3 deletions

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Production schedules should live in domain repositories and call this CLI or the
4141
quant-lifecycle monitor --domain us_equity
4242
quant-lifecycle drift --domain us_equity
4343
quant-lifecycle autopilot --domain us_equity --dry-run
44+
quant-lifecycle evidence --file path/to/evidence.json
4445
quant-lifecycle dashboard --format all
4546
```
4647

@@ -94,6 +95,9 @@ rw.update_secret("my-token", "new-token-value")
9495
```
9596

9697
## Useful docs
98+
- [`docs/strategy_lifecycle_policy.md`](docs/strategy_lifecycle_policy.md)
99+
- [`docs/strategy_portfolio_action_matrix.md`](docs/strategy_portfolio_action_matrix.md)
100+
- [`docs/evidence_package_template.md`](docs/evidence_package_template.md)
97101

98102
- [`docs/platform_notification_outcomes.md`](docs/platform_notification_outcomes.md)
99103
- [`docs/platform_notification_outcomes.zh-CN.md`](docs/platform_notification_outcomes.zh-CN.md)

README.zh-CN.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ python -m pytest -q
4141
quant-lifecycle monitor --domain us_equity
4242
quant-lifecycle drift --domain us_equity
4343
quant-lifecycle autopilot --domain us_equity --dry-run
44+
quant-lifecycle evidence --file path/to/evidence.json
4445
quant-lifecycle dashboard --format all
4546
```
4647

48+
## 延伸文档
49+
50+
- [`docs/strategy_lifecycle_policy.zh-CN.md`](docs/strategy_lifecycle_policy.zh-CN.md)
51+
- [`docs/strategy_portfolio_action_matrix.zh-CN.md`](docs/strategy_portfolio_action_matrix.zh-CN.md)
52+
- [`docs/evidence_package_template.zh-CN.md`](docs/evidence_package_template.zh-CN.md)
53+
4754
## 云服务抽象层
4855

4956
`quant_platform_kit.cloud` 包为常用云服务定义了协议接口——密钥管理、对象存储、文档数据库、计算发现和部署上下文。平台代码可以通过这些接口编写,无需硬编码到特定云厂商。

docs/ARCHITECTURE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Strategy profiles expose a common contract:
145145
| `name` | str | Profile name (snake_case) |
146146
| `domain` | str | Market domain (`us_equity`, `hk_equity`, `crypto`, `quant_combo`) |
147147
| `compatible_platforms` | list[str] | Allowed platform IDs |
148-
| `status` | str | `research_enabled` or `runtime_enabled` |
148+
| `status` | str | lifecycle stage, for example `research_backtest_only`, `shadow_candidate`, `live_candidate`, or `runtime_enabled` |
149149
| `evaluate()` | function | The pure decision function: `(ctx: StrategyContext) -> StrategyDecision` |
150150

151151
Strategy packages and their coverage:
@@ -158,7 +158,7 @@ Strategy packages and their coverage:
158158
| `crypto-strategies` | Crypto | Live pool rotation, BTC DCA, trend rotation, equity combo | BinancePlatform |
159159
| `quant-us-combo-strategies` | US Combo | Russell Top50 + IBIT (50/50), leveraged combo (TQQQ/SOXL/BOXX + SPY MA200) | Schwab, IBKR, LongBridge, Firstrade |
160160

161-
Catalog metadata is published through `get_runtime_enabled_profiles()` which platforms call to discover available strategies. Status promotion gates (`research_enabled` -> `runtime_enabled`) require passing evidence checks (backtest performance, drawdown limits, slippage tolerance).
161+
Catalog metadata is published through lifecycle-aware profile helpers which platforms call to discover available strategies. Status promotion gates (`research_backtest_only` -> `shadow_candidate` -> `live_candidate` -> `runtime_enabled`) require passing evidence checks (backtest performance, drawdown limits, slippage tolerance).
162162

163163
### 2.3 Snapshot Layer
164164

@@ -375,7 +375,7 @@ Exclusion lists handle strategies that are technically compatible but not yet ap
375375

376376
```python
377377
SCHWAB_EXCLUDED_LIVE_PROFILES = [
378-
"tecl_xlk_trend_income", # research_enabled, not cleared for live
378+
"tecl_xlk_trend_income", # research_backtest_only, not cleared for live
379379
"soxl_soxx_trend_income", # awaiting promo gate signoff
380380
]
381381
```

docs/STRATEGY_PLATFORM_SPEC.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ auto-sync layer described below.
2929

3030
## Adding a New Strategy
3131

32+
See also: [`strategy_lifecycle_policy.md`](./strategy_lifecycle_policy.md) for the
33+
promotion ladder and live-enable gate model.
34+
35+
Before requesting live enablement, attach an evidence package that covers:
36+
37+
- backtest summary
38+
- drift / regime notes
39+
- platform compatibility evidence
40+
- plugin gate status, if applicable
41+
3242
1. Add strategy definition to the shared catalog (`us_equity_strategies` or `hk_equity_strategies`)
3343
2. Set `compatible_platforms` to list which platforms support it
3444
3. Add to `runtime_enabled_profiles` for the rollout

docs/evidence_package_template.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Strategy Promotion Evidence Package
2+
3+
This template defines the minimum package to request `live_candidate` review.
4+
5+
## Required contents
6+
7+
- strategy profile name
8+
- target platform(s)
9+
- backtest summary
10+
- drift / regime notes
11+
- platform compatibility evidence
12+
- plugin gate status, if applicable
13+
- operator notes and rollout constraints
14+
15+
## Suggested structure
16+
17+
```text
18+
profile: cn_chinext_growth_momentum_quality
19+
market: cn_equity
20+
requested_stage: live_candidate
21+
22+
1. Backtest summary
23+
2. Drift and regime observations
24+
3. Risk review
25+
4. Platform compatibility evidence
26+
5. Plugin gate status
27+
6. Rollout notes
28+
```
29+
30+
## Acceptance rule
31+
32+
If any of the following are missing, keep the profile out of live settings:
33+
34+
- the profile is not runtime-compatible with the target platform
35+
- the plugin gate is not clearly approved or notification-only
36+
- the evidence does not cover both performance and regime sensitivity
37+
- the request is based on a single good window only
38+
39+
## Ownership
40+
41+
- strategy repo: produces the evidence package
42+
- platform repo: verifies runtime compatibility and gate status
43+
- operator review: makes the final live decision
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 策略晋级证据包
2+
3+
这份模板定义了请求 `live_candidate` 复核时最少应提交的内容。
4+
5+
## 必要内容
6+
7+
- 策略 profile 名称
8+
- 目标平台
9+
- 回测摘要
10+
- drift / regime 观察
11+
- 平台兼容性证据
12+
- 插件门槛状态(如适用)
13+
- 操作备注与 rollout 限制
14+
15+
## 建议结构
16+
17+
```text
18+
profile: cn_chinext_growth_momentum_quality
19+
market: cn_equity
20+
requested_stage: live_candidate
21+
22+
1. 回测摘要
23+
2. drift 与 regime 观察
24+
3. 风险复核
25+
4. 平台兼容性证据
26+
5. 插件门槛状态
27+
6. rollout 备注
28+
```
29+
30+
## 接受规则
31+
32+
如果缺少以下任一项,就应继续留在 live 之外:
33+
34+
- profile 与目标平台不兼容
35+
- 插件门槛不是明确 approved 或 notification-only
36+
- 证据没有同时覆盖收益表现和 regime 敏感性
37+
- 只依赖单一好窗口
38+
39+
## 责任划分
40+
41+
- 策略仓库:产出证据包
42+
- 平台仓库:验证 runtime 兼容性和门槛状态
43+
- 操作审批:做最终 live 决策

docs/strategy_lifecycle_policy.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Strategy Lifecycle Policy
2+
3+
[简体中文](./strategy_lifecycle_policy.zh-CN.md)
4+
5+
This document defines the lifecycle gates for strategy profiles across the
6+
quant repositories.
7+
8+
## Design Goal
9+
10+
The lifecycle should be permissive for research and monitoring, but strict for
11+
capital impact.
12+
13+
- AI monitoring may accelerate review and highlight drift.
14+
- AI monitoring must not bypass the live-enable gate.
15+
- A strategy can be observed earlier than it can trade.
16+
- Live enablement remains a platform decision, not just a backtest decision.
17+
18+
## Recommended Lifecycle Stages
19+
20+
| Stage | Meaning | Capital impact | Typical owner |
21+
| --- | --- | --- | --- |
22+
| `research_backtest_only` | Backtests, feature work, or evidence collection only | none | strategy repo |
23+
| `ai_monitored_candidate` | Eligible for AI review, drift scoring, and shadow tracking | none | strategy lifecycle |
24+
| `shadow_candidate` | Shadow runs are stable enough for repeatable comparisons | none | strategy lifecycle |
25+
| `live_candidate` | Passed validation and is awaiting platform enablement | gated | platform + strategy |
26+
| `runtime_enabled` | Exposed by `get_runtime_enabled_profiles()` and allowed in runtime settings | yes | platform repo |
27+
28+
### Practical interpretation
29+
30+
- `research_backtest_only` is the default for anything new.
31+
- `ai_monitored_candidate` is the lowest-friction review stage when the
32+
organization already has automated monitoring.
33+
- `shadow_candidate` should require repeatable shadow consistency, not just one
34+
good backtest.
35+
- `live_candidate` should only be used when the strategy has enough evidence to
36+
justify platform enablement.
37+
- `runtime_enabled` is the only stage that should influence live deployment
38+
defaults.
39+
40+
## Three-Gate Rule
41+
42+
A strategy should clear all three gates before live use:
43+
44+
1. **Strategy gate**
45+
- Does the strategy have enough history, risk characterization, and drift
46+
tolerance to move beyond research?
47+
2. **Plugin gate**
48+
- If the strategy depends on plugins, are those plugins at least
49+
`automation_approved` or explicitly `notification_only`?
50+
3. **Platform gate**
51+
- Does the target platform expose the profile via
52+
`get_runtime_enabled_profiles()` and accept the required runtime inputs?
53+
54+
Any one of these gates failing should keep the profile out of live settings.
55+
56+
## Recommended Promotion Policy
57+
58+
- Keep the monitoring threshold relatively low so candidates are visible early.
59+
- If AI monitoring already exists, use it to move promising profiles into
60+
`ai_monitored_candidate` quickly; this stage is for visibility, not capital.
61+
- Keep the live-enable threshold high so runtime exposure remains deliberate.
62+
- Prefer promotion by evidence package, not by ad hoc overrides. A promotion
63+
package should include backtest summary, drift notes, risk review, and
64+
platform compatibility evidence.
65+
- See [`evidence_package_template.md`](./evidence_package_template.md) for the
66+
recommended package shape.
67+
- When a strategy is a wrapper or orchestrator, promote it only after the
68+
wrapped components are stable and the wrapper itself has been validated.
69+
70+
## Repo-Level Guidance
71+
72+
- **US equity**: long-history trend / rotation profiles can move through the
73+
lifecycle earlier; wrapper combos should stay candidate-first.
74+
- **HK equity**: keep live exposure narrow and promote only stable runtime
75+
profiles.
76+
- **CN equity**: treat QMT-specific optional runtime profiles separately from
77+
the main live catalog.
78+
- **Crypto**: keep the monitoring stage permissive, but use a stricter live
79+
gate because regime shifts are faster.
80+
81+
## Operational Rule
82+
83+
If a profile is not returned by `get_runtime_enabled_profiles()`, it should
84+
stay out of live runtime settings regardless of monitoring status.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# 策略生命周期门槛策略
2+
3+
[English](./strategy_lifecycle_policy.md)
4+
5+
本文定义量化仓库中策略 profile 的生命周期门槛。
6+
7+
## 设计目标
8+
9+
生命周期应当对研究和监控保持宽松,但对资金影响保持严格。
10+
11+
- AI 监控可以加快复核和暴露 drift。
12+
- AI 监控不能绕过 live 启用门槛。
13+
- 策略可以先被观察,再允许交易。
14+
- live 启用仍然是平台决策,不只是回测结论。
15+
16+
## 推荐生命周期阶段
17+
18+
| 阶段 | 含义 | 资金影响 | 常见归属 |
19+
| --- | --- | --- | --- |
20+
| `research_backtest_only` | 仅回测、特征开发或证据收集 || 策略仓库 |
21+
| `ai_monitored_candidate` | 可进入 AI 复核、drift 打分和 shadow 跟踪 || 策略生命周期 |
22+
| `shadow_candidate` | shadow 运行已经稳定,可做重复对比 || 策略生命周期 |
23+
| `live_candidate` | 已通过验证,等待平台启用 | 受门槛控制 | 平台 + 策略 |
24+
| `runtime_enabled` | 会被 `get_runtime_enabled_profiles()` 暴露并允许进入运行时设置 || 平台仓库 |
25+
26+
### 实际含义
27+
28+
- `research_backtest_only` 适合作为所有新策略的默认起点。
29+
- 如果组织已经有自动监控,`ai_monitored_candidate` 可以作为最低摩擦的复核阶段。
30+
- `shadow_candidate` 应该要求重复 shadow 一致性,而不是只看一次漂亮回测。
31+
- `live_candidate` 只适合证据足够支持平台启用的策略。
32+
- `runtime_enabled` 才应该影响 live 配置默认值。
33+
34+
## 三道门槛
35+
36+
策略进入 live 之前,应同时通过三道门槛:
37+
38+
1. **策略门槛**
39+
- 是否具备足够的历史、风险画像和 drift 容忍度,能从研究阶段前进?
40+
2. **插件门槛**
41+
- 如果策略依赖插件,这些插件是否至少是 `automation_approved`
42+
或者被明确标记为 `notification_only`
43+
3. **平台门槛**
44+
- 目标平台是否通过 `get_runtime_enabled_profiles()` 暴露该 profile,
45+
并接受所需运行时输入?
46+
47+
任意一项不过关,都应该继续留在 live 之外。
48+
49+
## 推荐晋级策略
50+
51+
- 监控阈值可以相对低一些,让候选策略尽早可见。
52+
- 如果组织已经有自动 AI 监控,就用它尽快把合适的 profile 推到
53+
`ai_monitored_candidate`;这一层只为可见性,不为资金。
54+
- live 启用阈值要保持高一些,确保运行时暴露是明确决策。
55+
- 以证据包晋级,而不是临时 override。证据包至少应包含回测摘要、
56+
drift 记录、风险复核和平台兼容性证据。
57+
- 证据包建议结构见 [`evidence_package_template.zh-CN.md`](./evidence_package_template.zh-CN.md)
58+
- 如果策略是 wrapper / orchestrator,应先确认被包装组件稳定,再考虑给 wrapper 晋级。
59+
60+
## 仓库级建议
61+
62+
- **美股**:长历史趋势 / 轮动策略可以更早进入生命周期推进;wrapper combo 应优先保持 candidate 状态。
63+
- **港股**:保持 live 暴露范围窄,只晋级稳定的 runtime profile。
64+
- **A 股**:把 QMT 专用的可选 runtime profile 和主 live catalog 分开看待。
65+
- **加密货币**:监控阶段可以宽松一些,但 live 门槛应更严格,因为 regime 切换更快。
66+
67+
## 运行规则
68+
69+
如果某个 profile 没有被 `get_runtime_enabled_profiles()` 返回,那么它就不应该进入 live runtime settings,
70+
无论监控状态是否已经打开。

0 commit comments

Comments
 (0)