Xpersona
A

A Share Multifactor Model

CLAWHUB · Unverified

A股多因子模型/Barra风格因子分析。当用户说"多因子"、"multifactor"、"Barra"、"因子模型"、"风格因子"、"XX的因子暴露"、"因子收益率"、"风险模型"时触发。基于 cn-stock-data 获取行情和财务数据,构建多因子风险模型,分析因子暴露、因子收益、协方差矩阵。支持研报风格(f... Skill: A Share Multifactor Model Owner: yzswk Summary: A股多因子模型/Barra风格因子分析。当用户说"多因子"、"multifactor"、"Barra"、"因子模型"、"风格因子"、"XX的因子暴露"、"因子收益率"、"风险模型"时触发。基于 cn-stock-data 获取行情和财务数据,构建多因子风险模型,分析因子暴露、因子收益、协方差矩阵。支持研报风格(f... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-03-29T14:05:07.159Z | auto Initial release of the A股多因子模型 skill: - Supports Barra风格与自定义因子的多因子模型分析,自动触发关键词包括“多因子”、“Barra”、“因子模型”等。 - 集成 cn-stock-data 获取A股行

62
Rank
84
Safety
1.0k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17f5wmkcew8e0yrzrr8tjx7bh83h6td:a-share-multifactor-model
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-yzswk-a-share-multifactor-model/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

6,601 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

---
name: a-share-multifactor-model
description: A股多因子模型/Barra风格因子分析。当用户说"多因子"、"multifactor"、"Barra"、"因子模型"、"风格因子"、"XX的因子暴露"、"因子收益率"、"风险模型"时触发。基于 cn-stock-data 获取行情和财务数据,构建多因子风险模型,分析因子暴露、因子收益、协方差矩阵。支持研报风格(formal)和快速分析风格(brief)。
---

# A股多因子模型

## 数据源

```bash
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]
```

**量化计算**:
```bash
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: 因子计算与标准化
1. 从原始数据计算因子值
2. 去极值(MAD 法 ±3 倍)
3. 标准化(Z-score)
4. 缺失值处理(行业均值填充)

### Step 3: 截面回归估计因子收益
1. 每期对股票收益 vs 因子暴露做 OLS 回归
2. 回归系数即为因子收益率
3. 计算因子收益的 t 统计量

### Step 4: 构建风险模型
1. 因子协方差矩阵(指数加权)
2. 特质风险估计(回归残差的波动率)
3. 股票层面的风险分解

### Step 5: 输出

| 维度 | formal(完整因子报告) | brief(快速分析) |
|------|---------------------|-------------------|
| 因子定义 | 完整因子体系说明 | 仅列出因子名 |
| 因子收益 | 完整时序+统计检验 | 近期因子收益排名 |
| 暴露分析 | 个股因子暴露详表 | 关键因子暴露值 |
| 风险模型 | 协方差矩阵+特质风险 | 无 |
| 图表 | 因子收益累计曲线 | 无 |

默认风格:brief。用户要求"详细"/"完整模型"时切换为 formal。

## 关键规则
1. 因子暴露需经行业和市值中性化处理
2. 因子协方差使用半衰期 90 天的指数加权
3. 特质收益率需检验正态性假设
4. A 股需剔除 ST 股和次新股(上市<60日)
5. 行业分类默认使用申万一级(31 个行业)

_meta.json

{
  "ownerId": "kn744r09v2jvxpa7xejq9qwz8h838etq",
  "slug": "a-share-multifactor-model",
  "version": "1.0.0",
  "publishedAt": 1774793107159
}

references/multifactor-guide.md

# 多因子模型参考指南

## Barra CNE5/CNE6 模型概览

Barra 中国股票模型是 MSCI 开发的多因子风险模型,将股票收益分解为:
- **国家因子**:市场整体收益
- **行业因子**:31 个申万一级行业
- **风格因子**:10 个风格因子
- **特质收益**:个股特有的残差收益

### 10 大风格因子

| 因子 | 英文 | 计算方法 | A股数据来源 |
|------|------|---------|------------|
| 市值 | Size | ln(总市值) | quote |
| Beta | Beta | 对市场收益回归,252日窗口 | kline |
| 动量 | Momentum | 过去504日收益(去最近21日) | kline |
| 残差波动率 | Residual Volatility | 对市场回归残差的标准差 | kline |
| 非线性市值 | Non-linear Size | Size³ 对 Size 回归的残差 | quote |
| 账面市值比 | Book-to-Price | 净资产/总市值 | finance+quote |
| 流动性 | Liquidity | ln(过去21/63/252日平均换手率) | kline |
| 盈利收益率 | Earnings Yield | E/P + CF/P | finance+quote |
| 成长 | Growth | 营收增速 + 净利润增速 | finance |
| 杠杆 | Leverage | 资产负债率 + D/E + D/A | finance |

## 截面回归方法

### WLS(加权最小二乘)
- 权重 = sqrt(市值),减少小盘股噪声影响
- 每期回归模型:R_i = Σ(f_k × X_ik) + ε_i
  - R_i: 股票 i 的收益率
  - X_ik: 股票 i 对因子 k 的暴露
  - f_k: 因子 k 的收益率(回归系数)
  - ε_i: 特质收益

### 因子收益统计检验
- t 统计量 = f_k / se(f_k)
- |t| > 2 表示因子显著
- 年化因子收益 = mean(f_k) × 252
- 因子 IR = mean(f_k) / std(f_k) × sqrt(252)

## 协方差矩阵估计

### 因子协方差(F)
- 使用指数加权移动平均(EWMA)
- 半衰期 τ = 90 天:w_t = 2^(-t/τ)
- F_kl = Σ w_t × (f_k,t - μ_k)(f_l,t - μ_l) / Σ w_t

### 特质风险(Δ)
- 对角矩阵,每只股票一个特质波动率
- σ²_i = var(ε_i),同样使用 EWMA
- Newey-West 调整以处理自相关

### 总风险
- V = X × F × X' + Δ
  - V: 股票协方差矩阵 (N×N)
  - X: 因子暴露矩阵 (N×K)
  - F: 因子协方差矩阵 (K×K)
  - Δ: 特质风险对角矩阵 (N×N)

## 因子暴露标准化

1. **去极值**:MAD 法
   - median = median(x)
   - MAD = median(|x - median|)
   - 截断至 [median - 3×1.4826×MAD, median + 3×1.4826×MAD]

2. **标准化**:Z-score
   - z = (x - mean) / std

3. **行业/市值中性化**:
   - 对市值和行业哑变量回归,取残差作为中性化后的因子值

## A 股实践要点

1. **数据频率**:日频 K 线 + 季度财务,因子月度调仓
2. **行业分类**:申万一级(31 行业),部分研究用中信一级(29 行业)
3. **股票池**:剔除 ST、上市<60 天、停牌、涨跌停
4. **收益计算**:使用后复权价格
5. **因子滞后**:财务数据至少滞后一个季度,避免前视偏差

skill-card.md

## Description:

Provides Chinese-language A-share multifactor and Barra-style factor analysis, using market and financial data to build factor exposures, factor returns, and covariance outputs with brief or formal reporting styles.

This skill is ready for commercial/non-commercial use.

## Publisher:

[yzswk](https://clawhub.ai/user/yzswk)

### License/Terms of Use:

MIT-0

## Use Case:

Developers, analysts, and agent users use this skill to prepare A-share multifactor analysis, run local CSV-based factor regressions, and summarize exposures, factor returns, and risk-model statistics.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Financial analysis may be misleading if local CSV inputs, upstream market data, or model assumptions are stale or incorrect.

Mitigation: Review data sources, input files, and generated outputs before using results for financial decisions.

Risk: The skill may depend on a separate cn-stock-data skill for market and financial data collection.

Mitigation: Confirm the data dependency is installed and produces the expected A-share quote, kline, and finance inputs before running analysis.

## Reference(s):

- [Multifactor Guide](references/multifactor-guide.md)
- [ClawHub skill page](https://clawhub.ai/yzswk/skills/a-share-multifactor-model)
- [Publisher profile](https://clawhub.ai/user/yzswk)

## Skill Output:

**Output Type(s):** [text, markdown, code, shell commands, configuration, guidance]

**Output Format:** [Markdown guidance with shell commands and JSON analysis output from the local builder script]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Supports brief and formal reporting styles; the builder script reads local CSV returns and exposures and emits factor statistics, covariance values, and recent factor returns.]

## Skill Version(s):

1.0.0 (source: release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to A Share Multifactor Model and adjacent AI workflows.