Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By quantskillsGPL-3.0In 1 marketplace
Attributes active portfolio returns to industry allocation, stock selection, interaction, and factor contributions.
Claude hands work to one, or you mention it with @.
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
简体中文 | English
组合绩效归因 Skill:把组合相对基准的主动收益分解为行业配置、个股选择、交互效应与因子贡献,回答量化投资中回测之后的下一个问题——这笔超额收益到底赚在哪。
skill-portfolio-attribution 是 QuantSkills 社区的组合绩效归因 Skill。社区因子生态已覆盖挖掘、评估、衰减、合成、回测——本 Skill 补上信号变成组合之后缺失的一环:归因。
QuantSkills GitHub 组织:https://github.com/quantskills
回测报告告诉你组合年化超额 8%,但不会告诉你这 8% 来自哪里:是超配了对的行业,还是在行业内选对了股票,或是押中了动量、价值这类因子。归因把主动收益按来源精确拆开,各项加总严格等于区间主动收益。
本 Skill 提供两层归因:
两个面板对同一区间主动收益——因子归因与行业归因共用 Carino 缩放口径,因此因子面板合计恒等于行业面板合计,恒等于区间主动收益。
归因各项加总必须精确等于主动收益,这一恒等式内建为运行时断言:算不平即拒绝出报告。输入校验同样严格,不符合直接报错而非静默处理:
(date, symbol) 报错,避免 merge 时重复计权导致错误归因scripts/validate.py 用合成数据验证 13 项恒等式与护栏,包括"因子面板与行业面板对同一区间主动收益",全部通过pip install -r requirements.txt
# 自检(13 项恒等式与护栏)
python scripts/validate.py
# 端到端示例(合成组合,输出行业 + 因子归因)
python examples/run_example.py
# 用你自己的数据
python scripts/attribution.py \
--portfolio p.csv --benchmark b.csv --returns r.csv --sectors s.csv \
--exposures e.csv --out report/
示例输出(合成组合,故意超配半导体、低配银行):
区间主动收益 = +0.0599%
Brinson-Fachler 行业归因
组合权重 基准权重 配置 选股 交互 合计
半导体 41.25% 30.00% +0.05% +0.02% +0.01% +0.09%
银行 23.92% 35.00% -0.00% +0.04% -0.01% +0.02%
合计: 配置 +0.05% | 选股 +0.01% | 交互 -0.00% | 总计 +0.06%
因子归因(与行业归因对同一区间主动收益)
mom -0.16%
value +0.02%
特质/选股 +0.20%
合计 +0.06%
配置为正说明超配的半导体跑赢了基准;两个面板的合计都是 +0.06%,对上同一总账。
唯一需要提供的是每日持仓(来自任意回测、券商对账单或实盘账户,任何平台皆可):
date, symbol, weight # 或给 market_value,由 Agent 换算权重
20240102, 600519.SH, 0.20
20240102, CASH, 0.05 # 现金记一行,否则会漏掉现金拖累
其余三张由 Agent 从公开数据自动补齐:
qfq / Pandadata),close/pre_close 即干净日收益安全边界:本 skill 不含任何数据库连接/适配器,只吃"持仓 + 公开数据",绝不接入使用方私有库。把回测持仓导出成文件,是平台的职责。
skill-portfolio-attribution/
├── SKILL.md # Agent 使用说明(含 frontmatter)
├── README.md / README.en.md
├── agents/
│ ├── openai.yaml # OpenAI-style runtime manifest
│ ├── cursor-rule.mdc # Cursor rule entrypoint
│ └── portable-loader.md # Hermes/OpenClaw portable loader
├── scripts/
│ ├── attribution.py # Brinson + Carino + 因子归因 + 报告
│ └── validate.py # 13 项恒等式与护栏自检
├── references/
│ └── methodology.md # 方法论与公式
└── examples/
├── run_example.py
├── data/ # 合成输入
└── output/ # 归因报告示例(txt + json + html)
本 Skill 支持 Claude Code、Codex、Cursor、Hermes 和 OpenClaw。Claude Code、Codex 与原生 Skill 运行时直接加载 SKILL.md;Cursor 使用 agents/cursor-rule.mdc;Hermes/OpenClaw 在无法原生发现 Skill 时使用 agents/portable-loader.md。所有入口最终都回到同一份 SKILL.md、方法论和归因脚本,不维护平行业务逻辑。
CASH 行即计入现金拖累/贡献;不记则漏掉GPL-3.0。本 Skill 为 QuantSkills 社区原创,Brinson-Fachler 与 Carino 链接为组合归因通用方法。
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
portfolio-attribution@quantskills is listed by quantskills/registry — review the source before installing
npx claudepluginhub quantskills/registry --plugin portfolio-attributionPlugins from other owners that cover similar ground