返回顶部
p

private-fund-portfolio-analysis私募基金持仓分析

私募基金持仓结构分析脚本构建方法。支持市场中性(期货空头对冲)和指数增强(持仓 vs 对标指数超配/低配)两种产品类型。当需要从私募基金估值表(XLS/XLSX)解析持仓,分析行业分布/市值分布/指数成分/期货对冲,并生成可视化报告时触发。也用于:生成持仓分析脚本、重构脚本、添加新数据源、修复脚本Bug、生成分析报告。

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.6.0
安全检测
已通过
97
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

private-fund-portfolio-analysis

私募基金持仓结构分析脚本构建

两种产品类型

类型命令说明
市场中性--type marketneutral期货空头,分析对冲端
指数增强
--type indexenhanced --benchmark 中证500 | 持仓 vs 对标指数超配/低配 |

脚本位置

  • - 市场中性版:/workspace/analyzeportfolio.py
  • 指数增强版:/workspace/analyzeportfolio_enhanced.py

使用方式

bash

市场中性


python3 analyzeportfolioenhanced.py --xls <估值表路径> --type market_neutral

指数增强(指定对标指数)

python3 analyzeportfolioenhanced.py --xls <估值表路径> --type index_enhanced --benchmark 中证500 python3 analyzeportfolioenhanced.py --xls <估值表路径> --type index_enhanced --benchmark 沪深300 python3 analyzeportfolioenhanced.py --xls <估值表路径> --type index_enhanced --benchmark 中证1000 python3 analyzeportfolioenhanced.py --xls <估值表路径> --type index_enhanced --benchmark 中证2000 python3 analyzeportfolioenhanced.py --xls <估值表路径> --type index_enhanced --benchmark 空气指增

XLS 解析要点

估值表结构(以 xlrd 读取,行65+有股票数据):

col0: 科目代码(层级结构,如 1102.01.01.600519 SH)
col1: 名称
col4: 数量(股数)
col5: 单位成本
col6: 累计成本
col8: 行情/结算价
col9: 市值 ← 持仓市值
col11: 估值增值/PnL

提取6位股票代码:从层级代码中用正则提取,如 1102.01.01.600519 SH → 600519

期货行(账户代码含 3102.03.01.):

  • - col4 = 手数
  • col5 = 昨日结算价
  • col9 = 今日结算价
  • 名义本金 = 今日结算价 × 乘数 × 手数

乘数:IF/IH = 300;IC/IM = 200

指数增强核心功能

超配/低配计算

超配(%) = 持仓行业市值占比 - 对标指数行业市值占比
正数 = 超配(相对于指数);负数 = 低配

只显示 |差值| > 0.5% 的行业(过滤噪音)

对标指数数据来源

对标指数代码数据源
沪深300000300ak.indexstockcons(000300)
中证500
000905 | ak.indexstockcons(000905) | | 中证1000 | 000852 | ak.indexstockcons(000852) | | 中证2000 | 932000 | ak.indexstockcons_csindex(932000) |

数据 Enrichment

  • - 市值:ak.stockzhaspotem() → 市场数据缓存 CSV
  • 行业:MySQL 股票申万行业分类(charset=utf8mb4)
  • 指数成分:AKShare

MySQL 连接(占位符)

python
conn = pymysql.connect(
host=os.environ.get(MYSQL_HOST, 43.138.222.153),
port=int(os.environ.get(MYSQL_PORT, 3306)),
user=os.environ.get(MYSQLUSER, readonlyuser),
password=os.environ.get(MYSQL_PASSWORD, w6w%vkXENC82PGZo),
database=os.environ.get(MYSQL_DATABASE, 指数行情数据库),
connect_timeout=8, charset=utf8mb4
)

输出文件

文件说明
portfolioanalysis.csv持仓明细(355只股票)
portfoliosummary.json
汇总统计 | | portfolio_report.png | 可视化报告 |

参考文档

  • - references/xlsstructure.md — XLS 行列结构详解
  • references/datasources.md — AKShare/MySQL 数据源配置
  • scripts/generateanalysisscript_prompt.py — 可直接粘贴给 Claude Code 的提示词

注意

  • - XLS 列位因模板不同可能有差异,建议用 print(row[:12]) 验证
  • MySQL charset 必须用 utf8mb4,否则中文字符报错
  • 中证2000 用 indexstockconscsindex(932000),稳定性高于 indexstock_cons
  • 不要 hardcode 任何真实密码/地址/产品名称

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 private-fund-portfolio-analysis-1776019938 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 private-fund-portfolio-analysis-1776019938 技能

通过命令行安装

skillhub install private-fund-portfolio-analysis-1776019938

下载

⬇ 下载 private-fund-portfolio-analysis v1.6.0(免费)

文件大小: 9.08 KB | 发布时间: 2026-4-13 11:36

v1.6.0 最新 2026-4-13 11:36
Version 1.6.0

- No file changes detected in this version.
- Documentation and usage instructions remain unchanged.
- All core functionalities and supported features are as previously described.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部