用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill portfolio-analysis命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Handles reading, populating, and saving .docx files using the python-docx library. Use this skill for any tasks involving template filling or modifying Word documents.
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
This skill includes search capability in 13F, such as fuzzy search a fund information using possibly inaccurate name, or fuzzy search a stock cusip info using its name.
基于 SOC 职业分类
正在显示 SKILL.md
| name | portfolio-analysis |
| description | Analyzing fund portfolios including AUM extraction, holdings counts, and portfolio composition |
Portfolio analysis involves extracting fund-level information (AUM, total holdings, composition) from 13-F filings and comparing across time periods.
Location: SUMMARYPAGE.tsv
import pandas as pd
def get_fund_aum(accession_number, summarypage_df):
"""
Extract AUM for a specific fund
"""
fund_summary = summarypage_df[
summarypage_df['ACCESSION_NUMBER'] == accession_number
]
# Look for AUM-related fields in the data
# Common field names: AUM, ASSETS_UNDER_MANAGEMENT, TOTALASSETS, etc.
# Check available columns first
available_cols = fund_summary.columns.tolist()
print(f"Available columns: {available_cols}")
# If found, extract and convert to numeric
for col in available_cols:
if 'AUM' in col.upper() or 'ASSET' in col.upper() or 'TOTAL' in col.upper():
try:
aum_value = pd.to_numeric(
fund_summary[col].iloc[0],
errors='coerce'
)
return aum_value
except:
continue
return None
# Usage
q3_summary = pd.read_csv('/root/2025-q3/SUMMARYPAGE.tsv', sep='\t')
aum = get_fund_aum('specific_accession_number', q3_summary)
def get_holdings_count(accession_number, infotable_df):
"""
Count the number of stocks held by a fund
"""
fund_holdings = infotable_df[
infotable_df['ACCESSION_NUMBER'] == accession_number
]
return len(fund_holdings)
# Usage
q3_infotable = pd.read_csv('/root/2025-q3/INFOTABLE.tsv', sep='\t')
holdings_count = get_holdings_count('specific_accession_number', q3_infotable)
print(f"Renaissance Technologies holds {holdings_count} stocks")
def analyze_portfolio_composition(accession_number, infotable_df):
"""
Analyze fund's portfolio composition
"""
fund_holdings = infotable_df[
infotable_df['ACCESSION_NUMBER'] == accession_number
].copy()
# Ensure VALUE is numeric (in thousands)
fund_holdings['VALUE'] = pd.to_numeric(fund_holdings['VALUE'], errors='coerce')
# Calculate statistics
total_portfolio_value = fund_holdings['VALUE'].sum() * 1000 # Convert to dollars
num_holdings = len(fund_holdings)
avg_position = total_portfolio_value / num_holdings if num_holdings > 0 else 0
# Get top positions
top_10 = fund_holdings.nlargest(10, 'VALUE')[
['NAMEOFISSUER', 'CUSIP', 'VALUE', 'SSHPRNAMT']
]
top_10['VALUE_MILLIONS'] = top_10['VALUE'].astype(float) / 1000
return {
'total_value_dollars': total_portfolio_value,
'num_holdings': num_holdings,
'avg_position_dollars': avg_position,
'top_10_positions': top_10,
'concentration': (top_10['VALUE'].sum() / fund_holdings['VALUE'].sum() * 100)
}
# Usage
composition = analyze_portfolio_composition('accession_number', q3_infotable)
()
()
()
()
(composition[])
def find_funds_holding_stock(cusip, infotable_df, coverpage_df=None):
"""
Find all funds holding a specific stock (by CUSIP)
"""
holdings = infotable_df[infotable_df['CUSIP'] == cusip].copy()
if len(holdings) == 0:
return pd.DataFrame()
# Optional: Enrich with fund names from coverpage
if coverpage_df is not None:
holdings = holdings.merge(
coverpage_df[['ACCESSION_NUMBER', 'FILINGMANAGER_NAME']],
on='ACCESSION_NUMBER',
how='left'
)
# Sort by value (descending)
holdings['VALUE'] = pd.to_numeric(holdings['VALUE'], errors='coerce')
return holdings.sort_values('VALUE', ascending=False)
# Usage
q3_infotable = pd.read_csv('/root/2025-q3/INFOTABLE.tsv', sep='\t')
q3_coverpage = pd.read_csv('/root/2025-q3/COVERPAGE.tsv', sep='\t')
# Find who's holding Palantir (CUSIP: 69608A702)
palantir_holders = find_funds_holding_stock('69608A702', q3_infotable, q3_coverpage)
print(palantir_holders[['FILINGMANAGER_NAME', 'VALUE', 'SSHPRNAMT']])
import pandas as pd
def comprehensive_fund_analysis(accession_number, q_infotable, q_summarypage, q_coverpage):
"""
Complete analysis of a fund for a quarter
"""
# Get fund info
fund_info = q_coverpage[
q_coverpage['ACCESSION_NUMBER'] == accession_number
].iloc[0]
# Get holdings
holdings = q_infotable[
q_infotable['ACCESSION_NUMBER'] == accession_number
].copy()
holdings['VALUE'] = pd.to_numeric(holdings['VALUE'], errors='coerce')
# Get AUM
summary = q_summarypage[
q_summarypage['ACCESSION_NUMBER'] == accession_number
]
analysis = {
'fund_name': fund_info['FILINGMANAGER_NAME'],
'accession_number': accession_number,
'quarter': fund_info['REPORTCALENDARORQUARTER'],
'num_holdings': len(holdings),
'total_portfolio_value_thousands': holdings['VALUE'].sum(),
'top_5_positions': holdings.nlargest(5, 'VALUE')[
['NAMEOFISSUER', 'CUSIP', 'VALUE']
].to_dict('records')
}
return analysis
# Usage
q3_infotable = pd.read_csv('/root/2025-q3/INFOTABLE.tsv', sep='\t')
q3_summarypage = pd.read_csv('/root/2025-q3/SUMMARYPAGE.tsv', sep='\t')
q3_coverpage = pd.read_csv('/root/2025-q3/COVERPAGE.tsv', sep=)
analysis = comprehensive_fund_analysis(, q3_infotable, q3_summarypage, q3_coverpage)
()
()
()
def extract_aum_from_summarypage(accession_number, summarypage_df):
"""
Extract AUM from summarypage with fallback methods
"""
fund_row = summarypage_df[
summarypage_df['ACCESSION_NUMBER'] == accession_number
]
if fund_row.empty:
return None
fund_row = fund_row.iloc[0]
# Try different possible column names for AUM
possible_columns = [
'TABLE_OF_CONTENTS', # Sometimes contains AUM info
'AUM',
'TOTALASSETS',
'VALUE'
]
# Inspect all columns
for col in summarypage_df.columns:
if col in fund_row.index:
value = fund_row[col]
if pd.notna(value):
try:
numeric_val = pd.to_numeric(value, errors='coerce')
if numeric_val and numeric_val > 1000000: # Likely an AUM value (> 1M)
return numeric_val
except:
pass
return None
def calculate_performance_metrics(accession_q2, accession_q3, infotable_q2, infotable_q3):
"""
Calculate portfolio changes between quarters
"""
# Get holdings for both quarters
holdings_q2 = infotable_q2[infotable_q2['ACCESSION_NUMBER'] == accession_q2].copy()
holdings_q3 = infotable_q3[infotable_q3['ACCESSION_NUMBER'] == accession_q3].copy()
# Standardize column names and numeric types
for df in [holdings_q2, holdings_q3]:
df['VALUE'] = pd.to_numeric(df['VALUE'], errors='coerce')
df['SSHPRNAMT'] = pd.to_numeric(df['SSHPRNAMT'], errors='coerce')
# Merge on CUSIP
comparison = pd.merge(
holdings_q2[['CUSIP', 'NAMEOFISSUER', 'VALUE', 'SSHPRNAMT']],
holdings_q3[['CUSIP', 'VALUE', 'SSHPRNAMT']],
on='CUSIP',
how='outer',
suffixes=('_q2', '_q3')
).fillna(0)
# Calculate changes
comparison['value_change'] = comparison['VALUE_q3'] - comparison['VALUE_q2']
comparison['pct_change'] = (comparison['value_change'] / comparison['VALUE_q2'] * 100).replace([float('inf'), float('-inf')], 0)
return comparison.sort_values(, ascending=)
comparison = calculate_performance_metrics(
accession_q2, accession_q3,
q2_infotable, q3_infotable
)
top_increases = comparison[comparison[] > ].head()
(top_increases[[, , ]])
pd.to_numeric(df['VALUE'], errors='coerce')