Portfolio Analysis logo

Portfolio Analysis

Organization
cxcscmu
portfolio-analysis

Analyzing fund portfolios including AUM extraction, holdings counts, and portfolio composition

Overview

Publishercxcscmu
RepositorySkillLearnBench
Skill nameportfolio-analysis
Stars
91
Forks
7
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by cxcscmu on GitHub. Read the source before you install it.

Installation

Install the Portfolio Analysis AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/cxcscmu/SkillLearnBench/tree/main/skills/b1-one-shot-claude-haiku-4-5/financial-analysis/portfolio-analysis
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/cxcscmu/SkillLearnBench.git /tmp/SkillLearnBench
mkdir -p .claude/skills
cp -r /tmp/SkillLearnBench/skills/b1-one-shot-claude-haiku-4-5/financial-analysis/portfolio-analysis .claude/skills/portfolio-analysis
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Portfolio Analysis in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Portfolio Analysis on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Portfolio Analysis is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Portfolio Analysis for Hedge Funds

Overview

Portfolio analysis involves extracting fund-level information (AUM, total holdings, composition) from 13-F filings and comparing across time periods.

Key Metrics

1. Assets Under Management (AUM)

Location: SUMMARYPAGE.tsv

python
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)

2. Portfolio Holdings Count

python
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")

3. Portfolio Composition

python
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)
print(f"Total Portfolio Value: ${composition['total_value_dollars']:,.0f}")
print(f"Number of Holdings: {composition['num_holdings']}")
print(f"Top 10 Positions Concentration: {composition['concentration']:.2f}%")
print("\nTop 10 Positions:")
print(composition['top_10_positions'])

4. Finding Funds with Specific Stocks

python
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']])

Complete Fund Analysis Workflow

python
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='\t')

analysis = comprehensive_fund_analysis('0000320193-25-000069', q3_infotable, q3_summarypage, q3_coverpage)
print(f"Fund: {analysis['fund_name']}")
print(f"Holdings: {analysis['num_holdings']}")
print(f"Portfolio Value: ${analysis['total_portfolio_value_thousands'] * 1000:,.0f}")

Extracting AUM from SUMMARYPAGE

python
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

Performance Metrics

python
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('value_change', ascending=False)

# Usage
comparison = calculate_performance_metrics(
    accession_q2, accession_q3,
    q2_infotable, q3_infotable
)
top_increases = comparison[comparison['value_change'] > 0].head(5)
print(top_increases[['NAMEOFISSUER', 'CUSIP', 'value_change']])

Best Practices

  1. Always convert VALUE to numeric: pd.to_numeric(df['VALUE'], errors='coerce')
  2. Remember VALUE is in thousands: Multiply by 1000 for actual dollar amounts
  3. Handle missing accession numbers: Some funds may not file all quarters
  4. Validate cusip codes: Check for null or malformed CUSIPs
  5. Compare matching quarters: Q2 2025 vs Q3 2025, not Q2 2024 vs Q3 2025

Frequently asked questions

What does the Portfolio Analysis AI skill do?

Analyzing fund portfolios including AUM extraction, holdings counts, and portfolio composition

Why use Portfolio Analysis on TypingMind?

Because you install it once and use it with any model. Portfolio Analysis is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Portfolio Analysis in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/cxcscmu/SkillLearnBench/tree/main/skills/b1-one-shot-claude-haiku-4-5/financial-analysis/portfolio-analysis. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Portfolio Analysis?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Portfolio Analysis?

As many as you like. As long as a model supports skills, you can use Portfolio Analysis with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Portfolio Analysis AI skill free?

Yes. It is published on GitHub by cxcscmu under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇