Ml4t Position Sizing logo

Ml4t Position Sizing

Organization
ml4t
ml4t-position-sizing

Convert signals to position sizes using volatility targeting and risk budgets. Use when scaling trade size relative to conviction and portfolio risk.

Overview

Publisherml4t
Repositoryskills
Skill nameml4t-position-sizing
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 Position Sizing 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/position-sizing
  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/position-sizing .claude/skills/ml4t-position-sizing
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ml4t Position Sizing 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 Position Sizing 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 Position Sizing 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.

Position Sizing

Equal-weight portfolios ignore that a 1% position in a 40-vol crypto asset carries 8x the risk of a 1% position in a 5-vol bond ETF. Without volatility-aware sizing, portfolio risk is dominated by the noisiest assets.

The Problem

Signal-based strategies produce alpha scores, but scores are not position sizes. Naively allocating equal weight to every signal treats all assets as interchangeable. The result: a few high-volatility names drive total portfolio variance, drowning out the diversified signal you worked to build. Volatility targeting fixes this by scaling each position inversely to its risk.

The Pattern

WRONG

python
import numpy as np

# Equal weight: ignores that BTC vol >> SPY vol
signals = np.array([0.8, 0.6, 0.3, -0.5])
weights = signals / np.abs(signals).sum()  # [-0.36, 0.27, 0.14, -0.23]
# BTC at 40% vol gets same weight as SPY at 15% vol

CORRECT

python
import numpy as np

signals = np.array([0.8, 0.6, 0.3, -0.5])
realized_vol = np.array([0.40, 0.25, 0.15, 0.10])  # annualized
target_vol = 0.10  # 10% portfolio vol target

# Step 1: signal-proportional base weights
base = signals / np.abs(signals).sum()

# Step 2: scale each position by inverse volatility
vol_scalar = np.clip(target_vol / realized_vol, 0.5, 2.0)
raw = base * vol_scalar

# Step 3: enforce leverage constraint
max_leverage = 1.5
leverage = np.abs(raw).sum()
weights = raw * min(1.0, max_leverage / leverage)

Methods at a Glance

MethodFormulaWhen to Use
Equal weight1/NBaseline only
Signal-proportionalsignal / sum(|signal|)When signals are well-calibrated
Vol-targetedbase * (target_vol / asset_vol)Default for most strategies
Kellyexcess_return / varianceTheoretical bound; use half-Kelly
Risk budgettarget_risk / portfolio_riskFull portfolio vol targeting

Half-Kelly Sizing

python
def half_kelly(expected_excess: float, volatility: float) -> float:
    """Half-Kelly is the practical ceiling for position size."""
    full_kelly = expected_excess / (volatility ** 2)
    return full_kelly / 2  # halve to reduce variance of growth rate

Full Kelly maximizes long-run growth but has extreme variance. Half-Kelly sacrifices ~25% of growth for ~50% less variance in outcomes.

Guardrails

  • Never use full Kelly in production - half or quarter Kelly reduces ruin probability dramatically
  • Smooth volatility estimates with EWMA (halflife 20-60 days) - point estimates are noisy
  • Cap individual position size (e.g., 10% of NAV) regardless of signal strength
  • Recheck leverage after all position adjustments - constraint order matters

Production Implementation

ml4t-backtest handles position sizing inside the execution loop:

python
from ml4t.backtest import TargetWeightExecutor, RebalanceConfig

executor = TargetWeightExecutor(
    config=RebalanceConfig(
        max_single_weight=0.10,
        max_gross_leverage=1.5,
        min_weight_change=0.01,
    ),
)
orders = executor.execute(target_weights, data, broker)

Checklist

  • Positions scaled by inverse volatility (not equal-weighted)
  • Leverage cap enforced after all sizing adjustments
  • Individual position limits set (max 5-10% of NAV)
  • Volatility estimates smoothed (EWMA, not point-in-time)
  • Kelly fraction halved or quartered if used

Frequently asked questions

What does the Ml4t Position Sizing AI skill do?

Convert signals to position sizes using volatility targeting and risk budgets. Use when scaling trade size relative to conviction and portfolio risk.

Why use Ml4t Position Sizing on TypingMind?

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

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

Which AI models can use Ml4t Position Sizing?

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 Position Sizing?

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

Is the Ml4t Position Sizing 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 👇