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
当需要开发、计算、验证 CVaR 尾部风险最小化组合时,使用此 skill。在预期收益约束下最小化组合 95% CVaR,支持极值理论(EVT/GPD)尾部补样、组合权重求解、样本外验证。
Claude loads one when your task matches it, or you run it by name.
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
简体中文 | English
CVaR 尾部风险优化组合:在预期收益约束下最小化组合 95% CVaR,支持极值理论(EVT/GPD)尾部补样、组合权重求解、样本外验证与 HTML 可视化报告。
skill-portfolio-cvar-optim 是一个组合尾部风险优化 Skill,基于 Rockafellar-Uryasev 线性化方法,
在给定目标年化收益约束下最小化组合 CVaR@95%,并完成权重契约验证、样本外回测与离线复现。
这个 Skill 适合用于:
本 Skill 通过 panda_data SDK 拉取 A 股股票池(get_stock_daily)与基准指数(get_index_daily),
输出权重表、回测指标(CVaR/VaR/年化/MDD/Calmar)、HTML 可视化报告以及离线 fixture,便于 CI 集成。
scipy.optimize.linprog(method="highs") 求解| 文件 | 说明 |
|---|---|
SKILL.md | Skill 契约文档(Agent 内部使用,含完整公式) |
scripts/factor.py | CVaR 权重求解入口(收益矩阵 → EVT 补尾 → LP → 权重表,可独立运行) |
scripts/data_loader.py | 数据加载层(股票/指数日线 + parquet 缓存 + 字段标准化) |
scripts/validate.py | 权重验证(8 条契约 + 无未来函数 + 目标收益 + CVaR 一致性) |
scripts/backtest.py | 样本外回测(CVaR/年化/MDD + 等权/benchmark 对比) |
scripts/backtest_report_data.py | 回测时序数据包装层(HTML 报告数据源) |
scripts/report.py | HTML 报告生成入口(matplotlib 静态图,4 图 + 8 指标卡) |
scripts/save_fixture.py | 一次性生成离线测试 fixture(股票 + 指数,联网拉真实数据) |
scripts/_make_synthetic_fixture.py | 合成 fixture 生成器(无需联网,RandomState=42 自举) |
scripts/test_edge.py | 边界回归测试(LP 降级 / EVT 触发 / 确定性,pytest) |
scripts/analysis_report.py | 参数扫描深度分析(目标收益 / β → 有效前沿) |
scripts/fixtures/ | 离线测试数据(Parquet 格式) |
requirements.txt | Python 依赖清单 |
references/data_guide.md | PandaAI 数据接口参考 |
LICENSE | GPLv3 协议 |
README.md | 中文 README |
skill-portfolio-cvar-optim/
├── SKILL.md
├── README.md
├── LICENSE
├── requirements.txt
├── references/
│ └── data_guide.md
├── scripts/
│ ├── factor.py # CVaR 权重求解(EVT 补尾 + LP + optimize_portfolio + main)
│ ├── data_loader.py # 数据加载层(load_stock/index_data + 缓存 + 字段标准化)
│ ├── validate.py # 验证(8 条权重契约 + 无未来函数 + CVaR 一致性)
│ ├── backtest.py # 样本外回测(CVaR/VaR/年化/MDD/Calmar + 等权/benchmark)
│ ├── backtest_report_data.py # 回测时序数据包装层(保留 curve / drawdown / loss_hist)
│ ├── report.py # HTML 报告(4 图 + 8 指标卡 + 三方对比 + 权重明细)
│ ├── save_fixture.py # 生成离线 fixture(联网真实数据)
│ ├── _make_synthetic_fixture.py # 合成 fixture(无凭证自举,RandomState=42)
│ ├── analysis_report.py # 参数扫描 + CVaR-收益有效前沿
│ ├── test_edge.py # 边界回归测试(pytest)
│ ├── conftest.py # pytest 配置(默认离线 + stub 注入)
│ └── fixtures/
│ ├── sample_stocks.parquet # 离线股票数据
│ └── sample_index.parquet # 离线指数数据
# 1. 安装依赖
pip install -r requirements.txt
# 2. 配置数据源凭证
export PANDA_DATA_USERNAME=...
export PANDA_DATA_PASSWORD=...
# 3. 联网求解 + 验证 + 回测 + 报告
python scripts/factor.py
python scripts/validate.py
python scripts/backtest.py
python scripts/report.py
# 或离线模式(需先跑一次 save_fixture.py)
export PANDA_DATA_OFFLINE=1
python scripts/validate.py
python scripts/report.py --offline
权重表(每个资产一行):
| symbol | weight | expected_annual_return | tail_contribution |
|---|---|---|---|
| 000333.SZ | 0.3000 | 16.78% | 0.004876 |
| 600900.SH | 0.2345 | -4.68% | 0.003192 |
| ... | ... | ... | ... |
组合级指标:CVaR95 / VaR95 / 预期年化 / 目标收益 / EVT 补样记录,存于 DataFrame.attrs。
GPLv3
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-cvar-optim@quantskills is listed by quantskills/registry — review the source before installing
npx claudepluginhub quantskills/registry --plugin portfolio-cvar-optimPlugins from other owners that cover similar ground