A股多因子模型
SkillCommerce & financeA-share multifactor model / Barra-style factor analysis. Triggered when the user says "多因子", "multifactor", "Barra", "因子模型", "风格因子", "XX的因子暴露", "因子收益率", or "风险模型". Uses cn-stock-data to obtain market and financial data, builds a multifactor risk model, and analyzes factor exposure, factor returns, a
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the A股多因子模型 skill
What this skill tells your AI
The instructions your AI receives, as published by aifinlab/finclaw in skills/a-share-multifactor-model/SKILL.md and read by ahel’s review.
数据源
SCRIPTS="$SKILLS_ROOT/cn-stock-data/scripts"
# 个股K线(计算动量/波动率因子)
python "$SCRIPTS/cn_stock_data.py" kline --code [CODE] --freq daily --start [日期]
# 实时行情(市值/PE/PB等)
python "$SCRIPTS/cn_stock_data.py" quote --code [CODE1],[CODE2],...
# 财务指标(ROE/营收增速等基本面因子)
python "$SCRIPTS/cn_stock_data.py" finance --code [CODE]
量化计算:
QSCRIPTS="$SKILLS_ROOT/a-share-multifactor-model/scripts"
# 多因子回归
python "$QSCRIPTS/multifactor_builder.py" --returns returns.csv --factors "size,value,momentum" --method ols
Workflow
Step 1: 确定因子体系
根据用户需求选择因子集:
- Barra CNE5 风格:Size/Beta/Momentum/ResidVol/NLSize/BP/Liquidity/EarningsYield/Growth/Leverage
- 自定义因子:用户指定的因子组合
- 通过 cn-stock-data 获取原始数据(行情+财务)
Step 2: 因子计算与标准化
- 从原始数据计算因子值
- 去极值(MAD 法 ±3 倍)
- 标准化(Z-score)
- 缺失值处理(行业均值填充)
Step 3: 截面回归估计因子收益
- 每期对股票收益 vs 因子暴露做 OLS 回归
- 回归系数即为因子收益率
- 计算因子收益的 t 统计量
Step 4: 构建风险模型
- 因子协方差矩阵(指数加权)
- 特质风险估计(回归残差的波动率)
- 股票层面的风险分解
Step 5: 输出
| 维度 | formal(完整因子报告) | brief(快速分析) |
|---|---|---|
| 因子定义 | 完整因子体系说明 | 仅列出因子名 |
| 因子收益 | 完整时序+统计检验 | 近期因子收益排名 |
| 暴露分析 | 个股因子暴露详表 | 关键因子暴露值 |
| 风险模型 | 协方差矩阵+特质风险 | 无 |
| 图表 | 因子收益累计曲线 | 无 |
默认风格:brief。用户要求"详细"/"完整模型"时切换为 formal。
关键规则
- 因子暴露需经行业和市值中性化处理
- 因子协方差使用半衰期 90 天的指数加权
- 特质收益率需检验正态性假设
- A 股需剔除 ST 股和次新股(上市<60日)
- 行业分类默认使用申万一级(31 个行业)
Signals
- GitHub stars
- 241
- Forks
- 38
- Last commit
- May 2026
Advanced
- Catalog kind
- skill
- Gateway key
a-share-multifactor-model- Source
- github.com/aifinlab/finclaw