Ml4t Stress Test logo

Ml4t Stress Test

Organization
ml4t
ml4t-stress-test

Test portfolios against historical crises and hypothetical shocks. Use when quantifying tail risk before deployment or during risk reviews.

Overview

Publisherml4t
Repositoryskills
Skill nameml4t-stress-test
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 Stress Test 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/stress-test
  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/stress-test .claude/skills/ml4t-stress-test
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ml4t Stress Test 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 Stress Test 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 Stress Test 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.

Stress Testing

A strategy backtested on 2015-2023 has never seen a regime where equities and bonds fall simultaneously. Without stress testing against 2008, 2020, and 2022, you are implicitly betting that those regimes will not recur.

The Problem

Backtests cover only the historical sample, which may exclude the scenarios most relevant to survival. A momentum strategy backtested from 2010 onward has never experienced the 2009 momentum crash (-46% in one month). Stress testing applies known crisis scenarios and hypothetical shocks to the current portfolio, revealing exposures that summary statistics hide. This is not optional - it is how you discover that your "diversified" portfolio has a hidden correlation spike that produces a -30% month.

The Pattern

WRONG

python
import numpy as np

# Only looks at backtest period (2016-2023) - misses major crises
returns = backtest_returns  # 2016-2023 daily
max_loss = returns.min()
print(f"Worst day: {max_loss:.1%}")  # -3.2%, looks safe
# But GFC 2008 would have been -15% in a single week for this portfolio

CORRECT

python
import numpy as np

# Define crisis scenarios as asset-class shocks
SCENARIOS = {
    "GFC 2008":       {"equity": -0.50, "bond": +0.15, "credit": -0.30, "vol": +3.0},
    "COVID Mar 2020":  {"equity": -0.34, "bond": +0.08, "credit": -0.15, "vol": +4.0},
    "Rate Shock 2022": {"equity": -0.20, "bond": -0.15, "credit": -0.10, "vol": +1.5},
    "Correlation Spike":{"equity": -0.25, "bond": -0.10, "credit": -0.20, "vol": +2.0},
}

# Apply each scenario to current portfolio weights
weights = np.array([0.40, 0.30, 0.20, 0.10])  # equity, bond, credit, vol
asset_classes = ["equity", "bond", "credit", "vol"]

for name, shocks in SCENARIOS.items():
    pnl = sum(weights[i] * shocks.get(ac, 0) for i, ac in enumerate(asset_classes))
    survives = pnl > -0.20  # survival threshold
    print(f"{name:25s} PnL: {pnl:+.1%}  {'OK' if survives else 'BREACH'}")

Factor Stress Testing

python
def factor_stress(weights, factor_betas, factor_shocks):
    """Stress via factor exposures rather than asset classes.

    factor_betas: (n_assets, n_factors) from regression
    factor_shocks: dict of factor_name -> shock magnitude
    """
    shocks = np.array([factor_shocks[f] for f in factor_names])
    asset_impacts = factor_betas @ shocks
    return weights @ asset_impacts

# Example: what if momentum factor drops 3 sigma?
loss = factor_stress(weights, betas, {"momentum": -0.15, "value": 0.05})

Hypothetical Scenarios to Always Include

ScenarioKey FeatureWhy It Matters
2008 GFCEquity crash + credit freezeTests leverage and liquidity
2020 COVIDFastest drawdown in historyTests execution under vol spike
2022 Rate ShockBonds and equities fall togetherTests diversification assumption
Correlation spikeAll correlations go to 0.8Tests if hedges actually work
Liquidity freeze5x normal bid-ask spreadsTests transaction cost sensitivity

Guardrails

  • Historical scenarios are a floor, not a ceiling - always include a "2x worst" hypothetical
  • Correlations increase under stress - use stressed correlations, not normal-regime estimates
  • Test at current positions, not average or target weights
  • Update scenario library when new crises occur (each one reveals a new failure mode)

Checklist

  • At least 3 historical crisis scenarios applied (2008, 2020, 2022)
  • At least 1 hypothetical scenario (correlation spike or liquidity freeze)
  • Survival threshold defined (e.g., max -20% in any scenario)
  • Factor exposures stress-tested (not just asset-class proxies)
  • Scenario library reviewed and updated within last 12 months

Frequently asked questions

What does the Ml4t Stress Test AI skill do?

Test portfolios against historical crises and hypothetical shocks. Use when quantifying tail risk before deployment or during risk reviews.

Why use Ml4t Stress Test on TypingMind?

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

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

Which AI models can use Ml4t Stress Test?

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 Stress Test?

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

Is the Ml4t Stress Test 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 👇