Skip to content

Commit 51bfd5d

Browse files
committed
Mark theme momentum as medium horizon context
1 parent 79ca409 commit 51bfd5d

6 files changed

Lines changed: 53 additions & 8 deletions

File tree

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ rename such as `LongHorizonResearchSignals` can be considered, but that should
9797
be a separate migration because GitHub repo links, cross-repo checkout paths,
9898
and documentation references would all need updates.
9999

100+
101+
## Horizon Boundary
102+
103+
This repository does not directly produce short-term buy/sell recommendations.
104+
The horizon split is:
105+
106+
- Short term (`1-10 trading days`): handled by event evidence from `PoliticalEventTrackingResearch` plus deterministic Advisor rules. AI can explain context but should not decide short-term recommendations.
107+
- Medium term (`2-12 weeks`): represented by `theme_momentum_snapshot.json` as `medium_horizon_theme_context`, including theme momentum, breadth, and strong members inside each theme.
108+
- Long term (`1-3 years`): represented by `latest_signal.json` and `signal_history/*.json` as AI shadow context.
109+
110+
`QuantAdvisorResearch` remains the only layer that combines these inputs into final short/medium/long recommendations.
111+
100112
## GitHub Configuration
101113

102114
The model API keys are centralized in `CodexAuditBridge`; do not add
@@ -246,7 +258,8 @@ saved artifacts rather than regenerating historical AI judgments.
246258
## Scheduled Theme Momentum Refresh
247259

248260
`.github/workflows/theme_momentum_snapshot.yml` runs weekly before the advisor
249-
publication workflow. It builds `data/output/theme_momentum_snapshot.json` and,
261+
publication workflow. It builds `data/output/theme_momentum_snapshot.json` as
262+
`medium_horizon_theme_context` for the `2-12 weeks` horizon and,
250263
on scheduled runs, commits the changed snapshot back to the repository so
251264
`QuantAdvisorResearch` can consume a point-in-time artifact. Manual runs can pass
252265
`prices_path` to use an audited local CSV instead of Yahoo chart downloads.
@@ -275,7 +288,7 @@ If `--prices` is omitted, the script downloads Yahoo chart data. Partial symbol
275288
failures are recorded in `data_quality.missing_price_symbols` by default;
276289
`--strict-downloads` turns those into hard failures.
277290

278-
The snapshot records fixed 12-1m, 6-1m, and 3m momentum windows, breadth, risk
291+
The snapshot records `artifact_type=medium_horizon_theme_context`, horizon metadata, fixed 12-1m, 6-1m, and 3m momentum windows, breadth, risk
279292
penalties, top symbols per theme, source metadata, and a policy block that keeps
280293
the artifact research-only. `data_quality.coverage` now records configured
281294
symbol count, priced symbol count, price coverage ratio, and symbols with

README.zh-CN.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ data/output/signal_history/2026-05-28.json
7575

7676
如果后续主题动量层明显扩展成更通用的研究信号仓,可以单独评估改名,例如 `LongHorizonResearchSignals`。这需要迁移 GitHub 仓库链接、跨仓 checkout 路径和文档引用,不建议和本次数据质量增强混在一起做。
7777

78+
79+
## 短中长线边界
80+
81+
本仓库不直接输出短线买卖推荐。周期分工保持如下:
82+
83+
- 短线(1-10 个交易日):由 `PoliticalEventTrackingResearch` 的事件和 `QuantAdvisorResearch` 的确定性规则处理;AI 只可作为解释背景,不直接决定短线。
84+
- 中线(2-12 周):由本仓库的 `theme_momentum_snapshot.json` 提供 `medium_horizon_theme_context`,包括主题动量、主题广度和主题内强势标的。
85+
- 长线(1-3 年):由本仓库的 `latest_signal.json` / `signal_history/*.json` 提供 AI shadow context。
86+
87+
最终短线、中线、长线推荐统一由 `QuantAdvisorResearch` 合成,本仓库仍不下单、不配仓、不输出账户级建议。
88+
7889
## GitHub 配置
7990

8091
模型 API key 集中在 `CodexAuditBridge`;不要把 `OPENAI_API_KEY``ANTHROPIC_API_KEY` 放到本仓库。
@@ -199,7 +210,7 @@ config/symbol_theme_exposure.csv
199210

200211
## 主题动量定时刷新
201212

202-
`.github/workflows/theme_momentum_snapshot.yml` 每周在 Advisor 发布前运行,生成 `data/output/theme_momentum_snapshot.json`。定时运行时如果快照有变化,会提交回仓库,供 `QuantAdvisorResearch` 读取点时 artifact。手工运行可以传 `prices_path`,使用可审计的本地价格 CSV,而不是临时下载。
213+
`.github/workflows/theme_momentum_snapshot.yml` 每周在 Advisor 发布前运行,生成 `data/output/theme_momentum_snapshot.json`该 artifact 明确标记为 `medium_horizon_theme_context`,对应中线 2-12 周主题上下文。定时运行时如果快照有变化,会提交回仓库,供 `QuantAdvisorResearch` 读取点时 artifact。手工运行可以传 `prices_path`,使用可审计的本地价格 CSV,而不是临时下载。
203214

204215
Yahoo chart 下载仍然只是临时 fallback。使用本地价格 CSV 时,快照会记录来源和文件 hash。随机免费代理 IP 池不应进入稳定链路,因为它会增加 replay、数据质量和合规复核难度。
205216

@@ -222,6 +233,8 @@ python scripts/build_theme_momentum_snapshot.py \
222233

223234
- `theme_ranks`:主题排名、动量分、breadth、风险惩罚和主题内 top symbols
224235
- `methodology`:固定窗口和权重,便于后续 walk-forward replay
236+
- `artifact_type``medium_horizon_theme_context`,表示中线主题上下文,不是短线 AI 推荐
237+
- `horizon` / `horizon_window``medium` / `2-12 weeks`
225238
- `policy`:明确这是研究排序,不允许下单或仓位分配
226239
- `data_quality.coverage`:配置标的数、已有价格标的数、价格覆盖率和价格历史不足标的
227240

docs/architecture.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ This is the anti-overfit boundary:
117117
3. Replay only saved artifacts; never regenerate old model judgments.
118118
4. Treat theme bias as context, not as execution or allocation.
119119

120+
## Horizon Boundary
121+
122+
This repository should not directly produce short-term recommendations. Short-term (`1-10 trading days`) catalyst handling belongs to `PoliticalEventTrackingResearch` plus deterministic Advisor rules. `theme_momentum_snapshot.json` is explicitly a medium-horizon (`2-12 weeks`) theme context artifact, while `latest_signal.json` and `signal_history/*.json` remain long-horizon (`1-3 years`) AI shadow context. `QuantAdvisorResearch` is the final composition layer for short/medium/long recommendation buckets.
123+
120124
## Theme Momentum Snapshot
121125

122126
A cross-sector theme ranking is produced separately from the static taxonomy.
@@ -134,10 +138,10 @@ Output path convention:
134138
data/output/theme_momentum_snapshot.json
135139
```
136140

137-
The artifact is point-in-time research context. It ranks themes and highlights
138-
strong members inside a theme, but it does not encode orders, target weights, or
139-
execution policy. Future replay must consume saved snapshots rather than
140-
recomputing old theme ranks with revised constituents or revised weights.
141+
The artifact is point-in-time medium-horizon research context. It ranks themes and highlights
142+
strong members inside a theme, but it does not encode short-term recommendations,
143+
orders, target weights, or execution policy. Future replay must consume saved
144+
snapshots rather than recomputing old theme ranks with revised constituents or revised weights.
141145

142146
## Repository Name Decision
143147

scripts/build_theme_momentum_snapshot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def main() -> int:
104104
{
105105
"output": str(output_path),
106106
"as_of": snapshot["as_of"],
107+
"artifact_type": snapshot.get("artifact_type", ""),
108+
"horizon": snapshot.get("horizon", ""),
109+
"horizon_window": snapshot.get("horizon_window", ""),
107110
"ranked_theme_count": snapshot["summary"]["ranked_theme_count"],
108111
"priced_symbol_count": snapshot["summary"]["priced_symbol_count"],
109112
"top_theme_ids": snapshot["summary"]["top_theme_ids"],

src/ai_long_horizon_signal_pipelines/theme_momentum.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
DRAWDOWN_PENALTY_WEIGHT = 0.25
2222
BREADTH_BONUS_WEIGHT = 0.10
2323
DEFAULT_TOP_SYMBOLS = 5
24+
THEME_MOMENTUM_ARTIFACT_TYPE = "medium_horizon_theme_context"
25+
THEME_MOMENTUM_HORIZON = "medium"
26+
THEME_MOMENTUM_HORIZON_WINDOW = "2-12 weeks"
27+
THEME_MOMENTUM_HORIZON_WINDOW_ZH = "2-12周"
2428

2529

2630
def utc_now_iso() -> str:
@@ -218,6 +222,10 @@ def build_theme_momentum_snapshot(
218222
"as_of": snapshot_as_of,
219223
"generated_at": (generated_at or dt.datetime.now(dt.UTC)).isoformat().replace("+00:00", "Z"),
220224
"mode": "theme_momentum_snapshot",
225+
"artifact_type": THEME_MOMENTUM_ARTIFACT_TYPE,
226+
"horizon": THEME_MOMENTUM_HORIZON,
227+
"horizon_window": THEME_MOMENTUM_HORIZON_WINDOW,
228+
"horizon_window_label": THEME_MOMENTUM_HORIZON_WINDOW_ZH,
221229
"taxonomy_version": taxonomy_versions[0] if taxonomy_versions else "unknown",
222230
"methodology": {
223231
"windows": {
@@ -252,7 +260,7 @@ def build_theme_momentum_snapshot(
252260
"execution_allowed": False,
253261
"portfolio_allocation_allowed": False,
254262
"theme_rank_is_research_context_only": True,
255-
"downstream_use": "Theme momentum snapshot for research ranking and replay only; do not route to broker execution.",
263+
"downstream_use": "Medium-horizon theme context for research ranking and replay only; do not route to broker execution.",
256264
},
257265
}
258266

tests/test_theme_momentum.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ def test_theme_momentum_ranks_strong_broad_theme_first() -> None:
5757
)
5858

5959
ranked = snapshot["theme_ranks"]
60+
assert snapshot["artifact_type"] == "medium_horizon_theme_context"
61+
assert snapshot["horizon"] == "medium"
62+
assert snapshot["horizon_window"] == "2-12 weeks"
63+
assert snapshot["horizon_window_label"] == "2-12周"
6064
assert ranked[0]["theme_id"] == "hbm_memory"
6165
assert ranked[0]["rank"] == 1
6266
assert ranked[0]["breadth_3m"] == 1.0

0 commit comments

Comments
 (0)