Files
worldquant-alpha-system/docs/worldquant-knowledge-base/02-ai-mining/python-alpha.md
T
yuxuanhui a1b160e1b0 Update knowledge base with recent forum insights and clarifications
- Added new sections on missing data handling and experimental variables in data and signal semantics (2026-09-25).
- Included clarifications on clustering representatives and candidate evaluations in portfolio and correlation optimization (2026-09-25).
- Updated README to reflect the latest forum synchronization and new post counts, including significant additions and revisions across multiple topics (2026-09-25).
2026-09-25 10:38:15 +08:00

42 lines
5.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Python Alpha:先选对场景,再增加表达力
FastExpr 已能表达的简单机制,先用它建立基线。需要自定义变换、跨步状态或更复杂机器学习逻辑时,再评估 Python 的收益是否值得额外正确性与运行成本。
## 当前取得官方证据的边界
| 能力 | 官方说明 |
| --- | --- |
| 自定义计算 | 可自定义算子、复杂时序、持久状态、机器学习;清洗和公司行为调整责任增加 |
| API | 支持 `brain.simulate()`/`brain.simulate_async()`;Labs 外需 PYTHON 语言与 lookback 设置 |
| multi_sim | 不支持,仅单条 simulation |
| SuperAlpha | Python Alpha 不能作为组件 |
| Power Pool | Python Alpha 不符合参赛资格 |
| Pyramid / Genius signal | 官方分别答复可以计入 |
| 缩短日期范围 | start_date/end_date 仅用于 Labs simulation,不影响真实后台 simulation |
| 起步模板 | Labs 的 quick-start notebook 与 `alpha_example.py` |
来源:[What are the advantages of Python Alphas over Fast Expression Alphas?](https://support.worldquantbrain.com/hc/en-us/articles/41142997585943)(官方,更新 2026-08-30);[Can I run Python Alpha simulations via the API?](https://support.worldquantbrain.com/hc/en-us/articles/41143237730711)(官方,更新 2026-06-27);[Does Python Alpha support multi-simulation (multi_sim)?](https://support.worldquantbrain.com/hc/en-us/articles/41143256748183)(官方,更新 2026-06-27);[Can Python Alphas be selected as components in a SuperAlpha?](https://support.worldquantbrain.com/hc/en-us/articles/41143165313815)(官方,更新 2026-06-27);[Can Python Alphas be submitted in the Power Pool competition?](https://support.worldquantbrain.com/hc/en-us/articles/41143131195671)(官方,更新 2026-07-17);[Can a Python Alpha count toward my pyramid number?](https://support.worldquantbrain.com/hc/en-us/articles/41143114222999)(官方,更新 2026-07-17);[Do Python Alphas count toward my Genius signal count and cap?](https://support.worldquantbrain.com/hc/en-us/articles/41143111825303)(官方,更新 2026-07-17);[Can I simulate Python Alphas over a shorter date range?](https://support.worldquantbrain.com/hc/en-us/articles/41143262103191)(官方,更新 2026-06-12);[Are there any Python Alpha templates or example Alphas to start from?](https://support.worldquantbrain.com/hc/en-us/articles/41143071092119)(官方,更新 2026-06-27)。
## 转写必须做的对照(建议)
- 固定股票顺序、交易日、delay、mask、缺失哨兵、回填方式与 corporate actions 处理;缺失值不能一律填零。
- 区分截面 rank 与时序 rank;检查窗口是否包含当日、初始化多久、历史不足怎样处理。
- 对小样本逐日比较中间数组,再比较最终权重和 PnL;最终 Sharpe 相近不能证明数值等价。
- 行业中性化不等于减去全市场均值,pasteurize/neutralize/scale 的先后需要明确。
- 只有必要时持久化 state;保存状态会影响重启与复现,避免泄漏未来信息。
- 返回 dtype、形状、字段类型支持和 lookback 上限从当前 Labs 示例与实际接口核对,不照搬旧帖数字。
社区两阶段方法先 FastExpr 探测、再 Python 深化,有助于限制搜索成本;作者声称的耗时提升未经本次复现。5 月“lookback≤115”和 8 月“50–350”范围相冲突,因此本库不提供固定上限,也不沿用“不支持 GLB/GROUP/VECTOR”的历史断言。
来源:[[Python Alpha 挑战赛]Python Alpha两阶段筛选法:FastExpr快速验证 + Python深度优化](https://support.worldquantbrain.com/hc/en-us/community/posts/41135490599063)(发帖 2026-06-11,社区经验);[从 Fast 翻译到 Python Alpha 别急着炫技:截面/时序错位是头号杀手,事件漂移和中性化层级是隐形雷](https://support.worldquantbrain.com/hc/en-us/community/posts/42047259261335)(发帖 2026-07-18,社区经验);[【经验分享】Python Alpha 30名心得:从 FastExpr 到 Python,我用 17 个 alpha 趟出来的一条路](https://support.worldquantbrain.com/hc/en-us/community/posts/42519002511767)(发帖 2026-08-06,社区经验);[Python Alpha 平台限制粗略小结,请大佬指正](https://support.worldquantbrain.com/hc/en-us/community/posts/40742727142679)(发帖 2026-05-26,社区经验)。
本次没有安装或运行 BRAIN Labs Python SDK,所以这里只提供官方入口与迁移验证设计,不提供宣称可直接运行的 SDK 脚本。
## 2026-09-25 补充:频域与 PCA 实现先验算
[FFT 复现纠错帖](https://support.worldquantbrain.com/hc/en-us/community/posts/43640747372695)(2026-09-21)指出一个可直接验算的恒等式:对同一输入 x 的互补频带,slow + fast = x,因此 slow − x 与 −fast 是同一条腿,混合权重不会产生新信息。这只适用于所示互补分解及一致预处理,不能泛化为所有慢快信号必然共线。
原帖的其余“修正”仍需审查。对称 Hann 窗末端为零只能推出重构后的 slow[-1] + fast[-1] = 0,不能单凭这一点断言两个分量各自为零或必然衰减固定倍数。正文提倡前值填充,但修正版实际用窗口列均值填缺失;二者不是同一种经济假设。代码 `hist[-WIN:]` 在 WIN=65 时取 65 行,与注释宣称的 66 行也不一致。14–17 倍加速、泄漏比例和回测效果均为作者报告,本库未运行代码。
[PCA 特质残差反转帖](https://support.worldquantbrain.com/hc/en-us/community/posts/43692787685015)(2026-09-23)可作为待验证的自估风险模型思路,但代码 `cs[H-1:] - cs[:-H+1]` 每项相减的累计索引间隔为 H−1,不能直接标成 H 日收益和;它还将非有限收益填零,需核对缺失、上市历史与股票池影响。作者报告 IND 有效而 EUR/USA/HKG 不佳,并将 PnL 相关 0.963 称作“恒等变换”;这是近似经验,非数学恒等。不得照搬其地区结论或部分正交化系数。