← Back to Skills Marketplace
yzswk

A Share Multifactor Model

by yzswk · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
187
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install a-share-multifactor-model
Description
A股多因子模型/Barra风格因子分析。当用户说"多因子"、"multifactor"、"Barra"、"因子模型"、"风格因子"、"XX的因子暴露"、"因子收益率"、"风险模型"时触发。基于 cn-stock-data 获取行情和财务数据,构建多因子风险模型,分析因子暴露、因子收益、协方差矩阵。支持研报风格(f...
README (SKILL.md)

A股多因子模型

数据源

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: 因子计算与标准化

  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 股和次新股(上市\x3C60日)
  5. 行业分类默认使用申万一级(31 个行业)
Usage Guidance
This skill appears to do what it says: run local data-prep scripts and compute factor returns and covariances. Before installing, verify the following: 1) Confirm the referenced cn-stock-data scripts (under $SKILLS_ROOT/cn-stock-data) are trustworthy and inspect them for any network calls or credential usage, since SKILL.md assumes that dependency but doesn't declare it. 2) Ensure the CSV inputs you supply do not contain sensitive data you don't want processed. 3) Make sure required Python packages (pandas, numpy) are available in the environment. 4) Run the included multifactor_builder.py on test data in an isolated environment first to confirm outputs and that no unexpected I/O or network activity occurs.
Capability Analysis
Type: OpenClaw Skill Name: a-share-multifactor-model Version: 1.0.0 The skill is a legitimate quantitative finance tool for A-share multi-factor modeling and Barra style factor analysis. The Python script `scripts/multifactor_builder.py` implements standard statistical methods like WLS regression, MAD winsorization, and EWMA covariance for financial data processing without any network or unauthorized file access. The instructions in `SKILL.md` and the documentation are well-aligned with the stated purpose and contain no evidence of malicious intent or prompt injection.
Capability Assessment
Purpose & Capability
Name/description match the included assets: SKILL.md explains workflows for factor construction and the repository includes a multifactor_builder.py that implements cross-sectional regression, factor statistics, and EWMA covariance. No unrelated binaries, credentials, or config paths are requested.
Instruction Scope
Runtime instructions tell the agent to invoke cn-stock-data scripts under $SKILLS_ROOT and then run the local multifactor_builder.py. This is consistent with the described workflow, but the SKILL.md assumes the presence of a separate cn-stock-data skill at $SKILLS_ROOT (not declared as a dependency here). The instructions do not read arbitrary system files or exfiltrate data to external endpoints.
Install Mechanism
No install spec is provided (instruction-only with one helper script). No external downloads or package installs are invoked by the skill itself.
Credentials
The skill declares no required environment variables or credentials. The code reads CSV inputs (returns/exposures) and performs local numeric computations; it does not request tokens, secrets, or unrelated environment access.
Persistence & Privilege
always is false and the skill does not modify agent configuration or request permanent presence. It runs as-needed and prints results to stdout; no privileged persistence behavior is present.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install a-share-multifactor-model
  3. After installation, invoke the skill by name or use /a-share-multifactor-model
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of the A股多因子模型 skill: - Supports Barra风格与自定义因子的多因子模型分析,自动触发关键词包括“多因子”、“Barra”、“因子模型”等。 - 集成 cn-stock-data 获取A股行情与财务数据,自动构建因子、因子暴露、收益及协方差。 - 支持formal(研报)和brief(快速)两种报告风格,按用户需求切换输出细节。 - 实现因子标准化、去极值、缺失值处理,以及行业/市值中性化处理。 - 风险模型支持因子协方差(指数加权90天)、特质风险及股票分解分析。 - 默认剔除ST及上市不足60日新股,行业分类采用申万一级。
Metadata
Slug a-share-multifactor-model
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is A Share Multifactor Model?

A股多因子模型/Barra风格因子分析。当用户说"多因子"、"multifactor"、"Barra"、"因子模型"、"风格因子"、"XX的因子暴露"、"因子收益率"、"风险模型"时触发。基于 cn-stock-data 获取行情和财务数据,构建多因子风险模型,分析因子暴露、因子收益、协方差矩阵。支持研报风格(f... It is an AI Agent Skill for Claude Code / OpenClaw, with 187 downloads so far.

How do I install A Share Multifactor Model?

Run "/install a-share-multifactor-model" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is A Share Multifactor Model free?

Yes, A Share Multifactor Model is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does A Share Multifactor Model support?

A Share Multifactor Model is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created A Share Multifactor Model?

It is built and maintained by yzswk (@yzswk); the current version is v1.0.0.

💬 Comments