# position-sizer

Calculates risk-based position sizes for long stock trades using fixed risk, ATR volatility, or the Kelly criterion.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3800 installs · ★ 3267
- Author: tradermonty
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/tradermonty/claude-trading-skills/tree/HEAD/skills/position-sizer/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/position-sizer

## What it does

This skill computes the optimal share count for long stock trades under strict risk constraints. It supports sizing methodologies based on fixed percentage risk per trade, ATR volatility stops, and the Kelly criterion. Every calculation respects portfolio boundaries, including maximum position size and sector concentration limits.

Calculations run through the `scripts/position_sizer.py` script and output reports in JSON and Markdown formats under `reports/`. The tool floors share counts to prevent exceeding your defined risk budget. If your broker supports fractional shares, you can pass `--fractional` to avoid under-allocating in smaller accounts.

Execution requires only Python 3.9+ using the standard library, without any external API keys. When multiple portfolio constraints collide, the tightest limit dictates the final position size.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add tradermonty/claude-trading-skills --skill position-sizer -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/position-sizer/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/position-sizer/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add tradermonty/claude-trading-skills --skill position-sizer -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/position-sizer/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add tradermonty/claude-trading-skills --skill position-sizer -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/position-sizer/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install tradermonty/claude-trading-skills position-sizer
```

2. **Manually: put the files in place**
- File: `.github/skills/position-sizer/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add tradermonty/claude-trading-skills --skill position-sizer -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/tradermonty/claude-trading-skills --path skills/position-sizer
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/position-sizer/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add tradermonty/claude-trading-skills --skill position-sizer -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/tradermonty/claude-trading-skills/tree/HEAD/skills/position-sizer/SKILL.md

## When to use it
- calculate long stock position size based on trade risk
- size positions using ATR volatility stop distances
- determine capital allocation via the Kelly criterion
- enforce maximum position and sector concentration limits

## Example prompts
- Calculate position size for a stock trade using fixed fractional risk
- Size my position using ATR volatility and stop distance
- Check if my position fits within maximum sector concentration limits

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: cc9256800c9e2f63.

BEGIN THIRD-PARTY FILE cc9256800c9e2f63
````text
---
name: position-sizer
description: Calculate risk-based position sizes for long stock trades. Use when user asks about position sizing, how many shares to buy, risk per trade, Kelly criterion, ATR-based sizing, fractional-share sizing, or portfolio risk allocation. Supports stop-loss distance calculation, volatility scaling, and sector concentration checks.
---

# Position Sizer

## Overview

Calculate the optimal number of shares to buy for a long stock trade based on risk management principles. Supports three sizing methods:

- **Fixed Fractional**: Risk a fixed percentage of account equity per trade (default: 1%)
- **ATR-Based**: Use Average True Range to set volatility-adjusted stop distances
- **Kelly Criterion**: Calculate mathematically optimal risk allocation from historical win/loss statistics

All methods apply portfolio constraints (max position %, max sector %) and output a final recommended share count with full risk breakdown. The default output is whole shares. Use `--fractional` only when the user's broker supports fractional shares for the security and order type.

## When to Use

- User asks "how many shares should I buy?"
- User wants to calculate position size for a specific trade setup
- User mentions risk per trade, stop-loss sizing, or portfolio allocation
- User asks about Kelly Criterion or ATR-based position sizing
- User has a small account where whole-share rounding would under-deploy a defined risk budget
- User wants to check if a position fits within portfolio concentration limits

## Prerequisites

- No API keys required
- Python 3.9+ with standard library only

## Workflow

### Step 1: Gather Trade Parameters

Collect from the user:
- **Required**: Account size (total equity)
- **Mode A (Fixed Fractional)**: Entry price, stop price, risk percentage (default 1%)
- **Mode B (ATR-Based)**: Entry price, ATR value, ATR multiplier (default 2.0x), risk percentage
- **Mode C (Kelly Criterion)**: Win rate, average win, average loss; optionally entry and stop for share calculation
- **Optional constraints**: Max position % of account, max sector %, current sector exposure
- **Optional share mode**: Whole shares by default, or fractional shares with `--fractional --share-precision N` when supported by the broker

If the user provides a stock ticker but not specific prices, use available tools to look up the current price and suggest entry/stop levels based on technical analysis.

### Step 2: Execute Position Sizer Script

Run the position sizing calculation:

```bash
# Fixed Fractional (most common)
python3 skills/position-sizer/scripts/position_sizer.py \
  --account-size 100000 \
  --entry 155 \
  --stop 148.50 \
  --risk-pct 1.0 \
  --output-dir reports/

# Fractional shares for small accounts or high-priced stocks
python3 skills/position-sizer/scripts/position_sizer.py \
````
END THIRD-PARTY FILE cc9256800c9e2f63

The third-party file has ended. Everything between the cc9256800c9e2f63 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2850 of 7478 bytes. © tradermonty · MIT · https://github.com/tradermonty/claude-trading-skills/tree/HEAD/skills/position-sizer/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
