Ml4t Exposure Analysis logo

Ml4t Exposure Analysis

Organization
ml4t
ml4t-exposure-analysis

Decompose portfolio into factor, sector, and concentration exposures. Use when checking for unintended bets or risk concentrations.

Overview

Publisherml4t
Repositoryskills
Skill nameml4t-exposure-analysis
Stars
45
Forks
13
Bundled files
Instructions only
LicenseApache-2.0
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 ml4t on GitHub. Read the source before you install it.

Installation

Install the Ml4t Exposure 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/ml4t/skills/tree/main/portfolio/exposure-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/ml4t/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/portfolio/exposure-analysis .claude/skills/ml4t-exposure-analysis
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ml4t Exposure 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 Ml4t Exposure 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 Ml4t Exposure 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.

Exposure Analysis

A portfolio of 50 stocks can look diversified by count while having 80% of its risk in a single factor. Without exposure decomposition, you cannot distinguish between intended alpha bets and unintended factor tilts.

The Problem

Position weights tell you what you own, not what risks you are taking. A "diversified" tech-heavy portfolio may have a market beta of 1.4, a momentum loading of +0.6, and 60% sector concentration in technology - meaning most of its variance comes from three correlated bets, not 50 independent ones. Exposure analysis decomposes portfolio risk into factor loadings, sector weights, and concentration measures so you can verify that the portfolio matches your thesis.

The Pattern

WRONG

python
import numpy as np

# Only look at position weights
weights = np.array([0.05, 0.04, 0.03, ...])  # 50 stocks
print(f"Number of positions: {len(weights)}")
print(f"Max position: {weights.max():.1%}")
# "50 positions, max 5% - looks diversified!"
# But 35 of them are correlated growth stocks with beta > 1.3

CORRECT

python
import numpy as np
from sklearn.linear_model import LinearRegression

# Factor exposure via regression
# portfolio_returns: (T,), factor_returns: (T, K) - market, size, value, momentum
model = LinearRegression().fit(factor_returns, portfolio_returns)
betas = dict(zip(["market", "size", "value", "momentum"], model.coef_))
alpha = model.intercept_ * 252  # annualized

# Concentration: Herfindahl-Hirschman Index
hhi = (weights ** 2).sum()
effective_n = 1.0 / hhi  # equivalent number of equal-weight positions

# Net / gross exposure
net = weights.sum()
gross = np.abs(weights).sum()

print(f"Factor betas: {betas}")
print(f"Annualized alpha: {alpha:.2%}")
print(f"HHI: {hhi:.4f} (effective N={effective_n:.0f})")
print(f"Net: {net:.1%} | Gross: {gross:.1%}")

Sector Concentration

python
def sector_exposure(weights, sectors):
    """Aggregate weights by sector to detect concentration."""
    exposure = {}
    for w, s in zip(weights, sectors):
        exposure[s] = exposure.get(s, 0) + w
    return dict(sorted(exposure.items(), key=lambda x: -abs(x[1])))

# Flag any sector > 30% of gross exposure
for sector, wt in sector_exposure(weights, sectors).items():
    flag = " ** CONCENTRATED **" if abs(wt) > 0.30 else ""
    print(f"  {sector:20s} {wt:+.1%}{flag}")

Rolling Factor Exposures

Factor betas drift over time. Use rolling regression to detect style drift:

python
def rolling_betas(port_ret, factor_ret, window=63):
    """63-day rolling factor loadings."""
    T = len(port_ret)
    betas = np.full((T, factor_ret.shape[1]), np.nan)
    for t in range(window, T):
        model = LinearRegression().fit(
            factor_ret[t - window:t], port_ret[t - window:t])
        betas[t] = model.coef_
    return betas  # plot to see regime changes

Guardrails

  • Factor betas are unstable over short windows - use at least 63 days for daily data
  • Sector weights should align with investment thesis - large unintended tilts signal construction error
  • HHI above 0.10 (effective N < 10) means the portfolio is concentrated regardless of position count
  • Compare exposures to benchmark - net active bets should be intentional

Production Implementation

ml4t-diagnostic provides factor exposure and rolling attribution tools:

python
from ml4t.diagnostic.evaluation.factor import FactorAnalysis, FactorData

factor_data = FactorData.from_dataframe(factors_df, rf_column="RF")
analysis = FactorAnalysis(strategy_returns, factor_data)
static = analysis.static_model()
rolling = analysis.rolling_model(window=63)

Checklist

  • Factor exposures computed (market, size, value, momentum at minimum)
  • Sector/industry concentration measured and flagged if > 30%
  • HHI and effective N reported (not just position count)
  • Net and gross exposure tracked
  • Rolling betas monitored for style drift

Frequently asked questions

What does the Ml4t Exposure Analysis AI skill do?

Decompose portfolio into factor, sector, and concentration exposures. Use when checking for unintended bets or risk concentrations.

Why use Ml4t Exposure Analysis on TypingMind?

Because you install it once and use it with any model. Ml4t Exposure 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 Ml4t Exposure Analysis in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ml4t/skills/tree/main/portfolio/exposure-analysis. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Ml4t Exposure 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 Ml4t Exposure Analysis?

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

Is the Ml4t Exposure Analysis AI skill free?

Yes. It is published on GitHub by ml4t under the Apache-2.0 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 👇