跳到正文
Skillpedia
分析与电子表格37k · #7534

multi-factor

它能做什么

这项技能按多项指标为一组股票打分,并挑选排名最高的股票。适合一次性用大量股票构建投资组合的投资者。

适用场景

  • ✓当你想同时用多项指标从一组股票中挑出最好的股票的时候。
  • ✓当你想同时比较股票的动量、波动率和成交量的时候。
  • ✓当你想把排名最高的股票构建成等权重投资组合的时候。

技能链接

https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/multi-factor/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/multi-factor/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请按动量和波动率为这 50 只股票排名,并展示前 10 名。”

每周 5 个新技能,1 分钟读完。

工作原理

它会对每只股票在每个因子上打分,将分数标准化以便公平比较,然后把分数相加。得分最高的股票会以相等的权重进入投资组合。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Multi-Factor Cross-Sectional Stock Ranking

Purpose

On the same time cross-section, compute multiple factor values for many stocks, standardize them, combine them into a composite score, and select the top-ranked stocks to build a portfolio.

Signal Logic

  1. Factor calculation: calculate N factors for each stock (such as momentum, value, and quality)
  2. Cross-sectional standardization: standardize each factor on the cross-section with Z-score normalization (subtract mean, divide by standard deviation)
  3. Composite scoring: sum the factors with equal weights (or custom weights) to obtain a composite score
  4. Rank and select: go long the TopN names, with weight = 1/N for each

Built-In Factors

Factor Name Calculation Method Direction
momentum Return over the past N days Positive (higher is better)
reversal Return over the past 5 days Negative (lower is better)
volatility Standard deviation of returns over the past N days Negative (lower is better)
volume_ratio Today's volume / N-day average volume Positive

If extra_fields are available (China A-shares), you can also add:

  • pe_factor: 1/PE (the larger, the cheaper)
  • pb_factor: 1/PB
  • roe_factor: ROE (the larger, the better)

Parameters

Parameter Default Description
momentum_window 20 Momentum lookback window
vol_window 20 Volatility lookback window
top_n 3 Number of selected stocks
rebalance_freq 20 Rebalancing frequency (trading days)

Common Pitfalls

  • Cross-sectional standardization requires at least 3 stocks, otherwise Z-scores are meaningless
  • Keep the previous signal unchanged between rebalance dates (do not rerank every day)
  • Factors have different directions: momentum is positively sorted, volatility is negatively sorted, so directions must be aligned before standardization
  • Portfolio weights must be normalized: each TopN stock gets 1/N, all others get 0

Dependencies

pip install pandas numpy

Signal Convention

  • 1/N = selected into TopN (equal-weight long), 0 = not selected

Zoo Signal Engine (new in 0.1.8)

When the user wants to compose 1-N alphas drawn from the Alpha Zoo (450+ pre-built factors) into a multi-factor strategy, use ZooSignalEngine.from_zoo(...) from zoo_signal_engine.py instead of the old per-symbol example_signal_engine.py. The new engine operates on wide-panel dict[str, pd.DataFrame] inputs (the same shape the registry's Alpha.compute(panel) contract uses), redistributes weights when any alpha fails or is skipped, and supports long-only (top_n), short-only (bottom_n), and long-short (top_n + bottom_n) signal modes. It also exposes a generate(data_map) adapter so it drops straight into the existing run_backtest pipelines.

from src.factors.registry import Registry
from zoo_signal_engine import ZooSignalEngine

registry = Registry()
# Browse candidates with registry.list(theme="momentum") -- see the alpha-zoo skill.
alpha_ids = ["alpha101_001", "alpha101_012", "guotai_191_003"]
engine = ZooSignalEngine.from_zoo(alpha_ids, top_n=10, bottom_n=10, standardize=True)
# Feed into a panel-aware backtest, or via .generate(data_map) into the bundled engines.
signal_panel = engine.compute_signal(panel)  # DataFrame, same shape as panel["close"]

Cross-references:

  • See the alpha-zoo skill for browsing the alpha catalogue, filtering by theme/universe, and inspecting __alpha_meta__ records.
  • example_signal_engine.py is kept for legacy per-symbol workflows that compute factors directly from raw OHLCV; new code should prefer zoo_signal_engine.py so it benefits from the 450+ zoo alphas, registry-level NaN/inf guardrails, and per-alpha skip isolation.
常见问题

什么是因子?

因子是股票上可以衡量的特征,例如近期收益或价格波动的幅度。

我可以更改权重吗?

可以。该技能允许每个因子使用等权重或自定义权重。

内置了哪些因子?

包括动量、反转、波动率和成交量比率,在有数据时还会加入价值因子。

详情

作者的原始描述

Multi-factor cross-sectional stock ranking. Combines factor standardization, equal-weight or IC-weighted scoring, and TopN portfolio construction. Suitable for multi-instrument portfolio strategies.

repo: HKUDS/Vibe-Trading

热度

GitHub 星标
37k
排名
#7534
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能