Agent SkillsHKUDS/Vibe-Trading › multi-factor

multi-factor

GitHub

多因子横截面股票排序技能,用于计算、标准化并组合多个因子得分,构建TopN投资组合。支持动量、反转等内置因子及Alpha Zoo引擎,适用于量化选股策略。

agent/src/skills/multi-factor/SKILL.md HKUDS/Vibe-Trading

Trigger Scenarios

需要构建多因子选股模型 执行横截面因子标准化与合成 从Alpha Zoo组合因子生成信号

Install

npx skills add HKUDS/Vibe-Trading --skill multi-factor -g -y
More Options

Non-standard path

npx skills add https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/multi-factor -g -y

Use without installing

npx skills use HKUDS/Vibe-Trading@multi-factor

指定 Agent (Claude Code)

npx skills add HKUDS/Vibe-Trading --skill multi-factor -a claude-code -g -y

安装 repo 全部 skill

npx skills add HKUDS/Vibe-Trading --all -g -y

预览 repo 内 skill

npx skills add HKUDS/Vibe-Trading --list

SKILL.md

Frontmatter
{
    "name": "multi-factor",
    "category": "strategy",
    "description": "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."
}

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.

Version History

  • 0aa45a9 Current 2026-07-24 17:46

Same Skill Collection

agent/src/skills/adr-hshare/SKILL.md
agent/src/skills/akshare/SKILL.md
agent/src/skills/alpha-zoo/SKILL.md
agent/src/skills/ashare-pre-st-filter/SKILL.md
agent/src/skills/asset-allocation/SKILL.md
agent/src/skills/backtest-diagnose/SKILL.md
agent/src/skills/behavioral-finance/SKILL.md
agent/src/skills/candlestick/SKILL.md
agent/src/skills/ccxt/SKILL.md
agent/src/skills/chanlun/SKILL.md
agent/src/skills/commodity-analysis/SKILL.md
agent/src/skills/corporate-events/SKILL.md
agent/src/skills/correlation-analysis/SKILL.md
agent/src/skills/correlation-regime/SKILL.md
agent/src/skills/cross-market-strategy/SKILL.md
agent/src/skills/crypto-derivatives/SKILL.md
agent/src/skills/data-routing/SKILL.md
agent/src/skills/defi-yield/SKILL.md
agent/src/skills/dividend-analysis/SKILL.md
agent/src/skills/doc-reader/SKILL.md
agent/src/skills/earnings-forecast/SKILL.md
agent/src/skills/earnings-revision/SKILL.md
agent/src/skills/eastmoney/SKILL.md
agent/src/skills/edgar-sec-filings/SKILL.md
agent/src/skills/elliott-wave/SKILL.md
agent/src/skills/event-driven/SKILL.md
agent/src/skills/execution-model/SKILL.md
agent/src/skills/factor-research/SKILL.md
agent/src/skills/fund-analysis/SKILL.md
agent/src/skills/fundamental-filter/SKILL.md
agent/src/skills/geopolitical-risk/SKILL.md
agent/src/skills/global-macro/SKILL.md
agent/src/skills/harmonic/SKILL.md
agent/src/skills/hedging-strategy/SKILL.md
agent/src/skills/hk-connect-flow/SKILL.md
agent/src/skills/ichimoku/SKILL.md
agent/src/skills/investor-lenses/SKILL.md
agent/src/skills/liquidation-heatmap/SKILL.md
agent/src/skills/macro-analysis/SKILL.md
agent/src/skills/market-microstructure/SKILL.md
agent/src/skills/minute-analysis/SKILL.md
agent/src/skills/ml-strategy/SKILL.md
agent/src/skills/mootdx/SKILL.md
agent/src/skills/okx-market/SKILL.md
agent/src/skills/onchain-analysis/SKILL.md
agent/src/skills/options-advanced/SKILL.md
agent/src/skills/options-payoff/SKILL.md
agent/src/skills/options-strategy/SKILL.md
agent/src/skills/pair-trading/SKILL.md

Metadata

Files
0
Version
9806936
Hash
15de8eca
Indexed
2026-07-24 17:46

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 19:51
浙ICP备14020137号-1 $mapa de visitantes$