Agent skill

Position Sizing

by agiprolabs in agiprolabs/claude-trading-skills

Trade sizing methods including fixed fractional, volatility-adjusted, Kelly criterion, and liquidity-constrained sizing

MITAuto-check passed

Install Position Sizing

skills CLI
$ npx skills add agiprolabs/claude-trading-skills --skill position-sizing -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install agiprolabs/claude-trading-skills position-sizing --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/agiprolabs/claude-trading-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/position-sizing .claude/skills/position-sizing && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
position-sizing
GitHub stars
410
Token cost
~2.4k tokens
SKILL.md length
816 words
Files
5 (incl. scripts, references)
Skills in repo
68
Repo updated
First seen
Licence
MIT

At a glance

Trade sizing methods including fixed fractional, volatility-adjusted, Kelly criterion, and liquidity-constrained sizing

  • Works in 5 steps: Fixed Fractional Sizing → Volatility-Adjusted Sizing → Kelly Criterion → …
  • SKILL.md covers Methods Covered, 1. Fixed Fractional Sizing, 2. Volatility-Adjusted Sizing and 3. Kelly Criterion, plus 8 more sections
  • Runs Python scripts from its folder

What it does

Position Sizing is an agent skill from agiprolabs/claude-trading-skills. Trade sizing methods including fixed fractional, volatility-adjusted, Kelly criterion, and liquidity-constrained sizing

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts and reference files (for example `references/practical_guide.md`, `references/sizing_formulas.md` and `scripts/portfolio_sizer.py`).

The repository describes itself as: 68 trading, DeFi, and quantitative finance Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, and 30+ other tools. The licence is MIT.

Example prompts

  • “/position-sizing”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Fixed Fractional Sizing
  2. Volatility-Adjusted Sizing
  3. Kelly Criterion
  4. Liquidity-Constrained Sizing
  5. Anti-Martingale Sizing

What it can do on your machine

Read from SKILL.md and the folder at commit 981e1d7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Position Sizing loads about 2.4k tokens when it runs, and up to ~6k if it reads all its reference files. Until then it costs about 34 tokens; SKILL.md has 816 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~34
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from agiprolabs/claude-trading-skills at commit 981e1d7, republished under its MIT licence (© agiprolabs). 816 words, ~2,423 tokens.

Download SKILL.mdSave it as .claude/skills/position-sizing/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
position-sizing
description
Trade sizing methods including fixed fractional, volatility-adjusted, Kelly criterion, and liquidity-constrained sizing

Position Sizing

Position sizing is the single most important risk management decision in trading. Your entry signal determines direction; your position size determines survival. A mediocre strategy with proper sizing will outperform a great strategy with reckless sizing over any meaningful time horizon.

Core principle: Size determines survival, not entries. Two traders with the same signals but different sizing will have wildly different outcomes. The one who sizes conservatively survives drawdowns and compounds capital; the one who oversizes blows up.

Methods Covered

MethodBest ForKey Input
Fixed FractionalGeneral trading, most recommendedAccount risk %
Volatility-AdjustedVolatile markets, multi-assetATR or realized vol
Kelly CriterionQuantified edge with track recordWin rate + payoff ratio
Liquidity-ConstrainedLow-liquidity Solana tokensPool depth
Anti-MartingaleTrend-following strategiesRecent P&L streak

1. Fixed Fractional Sizing

The most recommended method for most traders. Risk a fixed percentage of your account on each trade.

Formula
risk_amount = account_value * risk_percentage
price_risk_per_unit = entry_price - stop_loss_price
position_size_units = risk_amount / price_risk_per_unit
position_value = position_size_units * entry_price
Risk Tiers
TierRisk Per TradeUse Case
Conservative0.5–1%New strategies, drawdown recovery
Standard1–2%Most traders, proven strategies
Aggressive3–5%High-conviction setups with strong, measured edge
Example
python
account = 10_000  # $10,000 or 100 SOL
risk_pct = 0.02   # 2%
entry = 1.50
stop_loss = 1.30

risk_amount = account * risk_pct          # $200
price_risk = entry - stop_loss            # $0.20
position_units = risk_amount / price_risk # 1,000 tokens
position_value = position_units * entry   # $1,500

With this sizing, if the stop loss is hit, you lose exactly 2% of your account regardless of the token's price or volatility.


2. Volatility-Adjusted Sizing

Scale position size inversely with volatility. When volatility is high, take smaller positions; when low, take larger positions. This normalizes the dollar risk across different market conditions.

Formula
adjusted_size = base_size * (target_vol / current_vol)

Where:

  • target_vol: your desired daily portfolio volatility (e.g., 2%)
  • current_vol: the token's current daily volatility (from ATR or realized vol)
Using ATR
python
atr_14 = 0.12          # 14-period ATR
close_price = 1.50
daily_vol_pct = atr_14 / close_price  # 8%

target_daily_vol = account * 0.02      # $200 target daily move
position_size = target_daily_vol / atr_14  # 1,667 units

This automatically reduces exposure in volatile markets and increases it in calm ones.


3. Kelly Criterion

The mathematically optimal fraction of capital to risk, maximizing long-term growth rate. Derived from maximizing expected logarithmic utility.

Formula
f* = (p * b - q) / b

Where:

  • p = win rate (probability of winning trade)
  • q = 1 - p (probability of losing trade)
  • b = average win / average loss (payoff ratio)
  • f* = optimal fraction of capital to risk

Equivalent form: f* = (p * (b + 1) - 1) / b

Critical Rule: NEVER Use Full Kelly

Full Kelly assumes perfect knowledge of your edge. In practice, edge estimates are noisy. Always use fractional Kelly:

FractionUse CaseNotes
0.25x KellyConservative, recommended defaultRobust to edge estimation error
0.50x KellyModerate, for well-measured edgesStill significant drawdown risk
1.0x KellyNever in practiceTheoretical maximum, catastrophic if edge is overestimated
Example
python
win_rate = 0.55       # 55% win rate
avg_win = 2.0         # Average win is 2x the average loss
avg_loss = 1.0
payoff_ratio = avg_win / avg_loss  # b = 2.0

kelly = (win_rate * payoff_ratio - (1 - win_rate)) / payoff_ratio
# kelly = (0.55 * 2.0 - 0.45) / 2.0 = 0.325 = 32.5%

quarter_kelly = kelly * 0.25  # 8.1% — use this
half_kelly = kelly * 0.50     # 16.25%

If Kelly is negative, you have no edge. Do not trade.

See references/sizing_formulas.md for the full mathematical derivation.


4. Liquidity-Constrained Sizing

Critical for Solana tokens. Even if your risk model says you can take a large position, the pool may not support it without unacceptable slippage.

Formula (Constant-Product AMM)
slippage ≈ trade_size / pool_liquidity
max_trade = pool_liquidity * max_slippage_pct
Rules of Thumb
ConstraintGuideline
Max single trade2% of pool liquidity
Max position5% of pool liquidity
Minimum pool depth10x your desired position size
Example
python
pool_sol = 500          # 500 SOL in pool
max_slippage = 0.02     # 2% max slippage

max_trade_sol = pool_sol * max_slippage  # 10 SOL
# For a $150 SOL price, that's $1,500 max per trade

Always check all pools, not just the largest. Aggregate liquidity across Raydium, Orca, and Meteora for the full picture. See the liquidity-analysis skill for pool depth assessment.


Show full SKILL.md (327 more words)Show less

5. Anti-Martingale Sizing

Increase size after wins, decrease after losses. This is the opposite of the gambler's fallacy (Martingale). The logic: winning streaks may indicate your strategy is in sync with the market; losing streaks may indicate regime change.

Implementation
python
def anti_martingale_size(
    base_size: float,
    consecutive_wins: int,
    consecutive_losses: int,
    scale_factor: float = 0.25,
    max_multiplier: float = 2.0,
    min_multiplier: float = 0.5,
) -> float:
    if consecutive_losses > 0:
        multiplier = max(min_multiplier, 1.0 - consecutive_losses * scale_factor)
    elif consecutive_wins > 0:
        multiplier = min(max_multiplier, 1.0 + consecutive_wins * scale_factor)
    else:
        multiplier = 1.0
    return base_size * multiplier

Use conservatively. After 3+ consecutive losses, reducing size by 50% protects capital during drawdowns.


Position Sizing Ladder

Combine all methods and take the most conservative result:

1. Calculate Kelly size          → theoretical max based on edge
2. Calculate fixed fractional    → risk-based size
3. Calculate volatility-adjusted → vol-normalized size
4. Calculate liquidity-constrained max → market-based ceiling
5. Final size = min(all four)    → binding constraint wins

The binding constraint tells you what is limiting your size:

  • Kelly-bound: your edge is small, size accordingly
  • Risk-bound: standard risk management is the limit
  • Volatility-bound: market is too volatile for larger size
  • Liquidity-bound: pool cannot absorb more without slippage

Account-Level Limits

Individual position sizing is necessary but not sufficient. You also need portfolio-level constraints:

LimitGuidelineRationale
Max single position10% of portfolioDiversification floor
Max correlated exposure25% of portfolioCorrelated assets move together
Max total exposure50–80% of portfolioCash reserve for opportunities/margin
Max positions5–10 concurrentAttention and management bandwidth

PumpFun / Meme Token Sizing

PumpFun and early-stage meme tokens require special sizing discipline:

  • Very small positions: 0.1–1 SOL per trade due to extreme risk
  • Scale with bonding curve fill %: smaller when early (high rug risk), slightly larger when proven (graduated to Raydium)
  • Never size based on expected return — size based on acceptable total loss
  • Treat as lottery tickets: expect most to go to zero
  • Position limit: no more than 5–10% of portfolio across all meme positions combined
python
# PumpFun sizing example
account_sol = 100
meme_budget = account_sol * 0.05   # 5 SOL total for memes
per_trade = meme_budget / 10       # 0.5 SOL each, 10 shots

Integration with Other Skills

SkillIntegration
risk-managementPortfolio-level limits, drawdown rules
liquidity-analysisPool depth data for liquidity constraints
kelly-criterionDeeper Kelly math, edge estimation
exit-strategiesStop loss placement affects fixed fractional sizing
volatility-modelingBetter vol estimates for volatility-adjusted sizing
slippage-modelingPrecise slippage estimates for liquidity constraints

Files

References
  • references/sizing_formulas.md — Mathematical derivations for all sizing methods with worked examples
  • references/practical_guide.md — Sizing by account size, token type, and common mistakes
Scripts
  • scripts/size_calculator.py — Calculates position size using all methods, shows binding constraint
  • scripts/portfolio_sizer.py — Portfolio risk dashboard with per-position risk and available budget

Quick Reference

python
# Minimal fixed fractional sizing — copy-paste starter
def calc_position_size(
    account: float, risk_pct: float, entry: float, stop: float
) -> float:
    """Return number of units to buy."""
    risk_amount = account * risk_pct
    price_risk = abs(entry - stop)
    if price_risk == 0:
        return 0.0
    return risk_amount / price_risk

© agiprolabs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/position-sizing of agiprolabs/claude-trading-skills.

  • SKILL.md
  • references/practical_guide.md
  • references/sizing_formulas.md
  • scripts/portfolio_sizer.py
  • scripts/size_calculator.py

Open the folder on GitHubat commit 981e1d7

Compare with similar skills

Position Sizing next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Position Sizing compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Position Sizing this skillagiprolabs/claude-trading-skills410—~2.4kAutomated safety check: PassMIT
Volatility Percentile StrategyHKUDS/Vibe-Trading35k—~528Automated safety check: PassMIT
Fixalirezarezvani/claude-skills28k1 repos~765Automated safety check: PassMIT
Agent Trading Predictorruvnet/ruflo74k3 repos~2.5kAutomated safety check: PassMIT
LLM Trading Agent Securityaffaan-m/ECC275k2 repos~1.2kAutomated safety check: PassMIT
Trade Journal AnalysisHKUDS/Vibe-Trading35k—~1.8kAutomated safety check: PassMIT

Similar skills

  • Mean-reversion signal engine that ranks historical volatility against its own recent history, going long in quiet regimes and exiting or shorting when volatility is high.

    35k GitHub stars~528 tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Fix

    alirezarezvani/claude-skills

    Fix failing or flaky Playwright tests. An agent skill from alirezarezvani/claude-skills.

    28k GitHub starsUsed in 1 repo~765 tokens
    Testing & QAAuto-check passed
  • Agent skill for trading-predictor - invoke with $agent-trading-predictor

    74k GitHub starsUsed in 3 repos~2.5k tokens
    Business, Finance & HRAuto-check passed
  • Security patterns for autonomous trading agents with wallet or transaction authority.

    275k GitHub starsUsed in 2 repos~1.2k tokens
    SecurityAuto-check passed
  • Trade Journal Analysis

    HKUDS/Vibe-Trading

    Reads a broker export of your trades (CSV or Excel), builds a trading profile and runs four behavior checks: disposition effect, overtrading, chasing and anchoring.

    35k GitHub stars~1.8k tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Volatility Trading

    agentii-ai/agentii-investment-intelligence

    volatility trading, VIX products, straddle strangle, vol arbitrage, volatility surface trading, variance swap, gamma scalping, implied vs realized volatility, vol of vol, earnings volatility play

    207 GitHub stars~1.1k tokensUpdated 9 days ago
    Business, Finance & HRAuto-check passed

More from agiprolabs/claude-trading-skills

All 68 skills in this repo
  • Backtrader

    agiprolabs/claude-trading-skills

    Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers, and custom indicators

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Birdeye API

    agiprolabs/claude-trading-skills

    Solana token market data via Birdeye — prices, OHLCV, trades, token metadata, security checks, and trader activity

    410 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Coingecko API

    agiprolabs/claude-trading-skills

    Broad crypto market data from CoinGecko covering 13,000+ tokens.

    410 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Cointegration Analysis

    agiprolabs/claude-trading-skills

    Cointegration testing for pairs trading using Engle-Granger, Johansen, and rolling stability analysis

    410 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Copy Trading

    agiprolabs/claude-trading-skills

    Wallet evaluation, monitoring, and copy-trade strategy design for Solana DEX trading

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Correlation Analysis

    agiprolabs/claude-trading-skills

    Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Position Sizing

What does Position Sizing do?

Trade sizing methods including fixed fractional, volatility-adjusted, Kelly criterion, and liquidity-constrained sizing. Position Sizing is an agent skill from agiprolabs/claude-trading-skills.

How do I install Position Sizing in Claude Code?

Run `npx skills add agiprolabs/claude-trading-skills --skill position-sizing -a claude-code`. Or copy the skill folder (skills/position-sizing in agiprolabs/claude-trading-skills) into .claude/skills/position-sizing in your project. Claude Code loads it when a task matches its description.

How do I install Position Sizing in Codex?

Run `npx skills add agiprolabs/claude-trading-skills --skill position-sizing -a codex`. Or copy the skill folder (skills/position-sizing in agiprolabs/claude-trading-skills) into .agents/skills/position-sizing in your project. Codex loads it when a task matches its description.

Can I use Position Sizing in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add agiprolabs/claude-trading-skills --skill position-sizing -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/position-sizing, .gemini/skills/position-sizing, .github/skills/position-sizing and .opencode/skills/position-sizing in your project.

What does Position Sizing need to run?

Going by SKILL.md and its folder, Position Sizing needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Position Sizing access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Position Sizing safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Position Sizing use?

Position Sizing is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Position Sizing use?

About 2.4k tokens (SKILL.md is roughly 9.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.6k tokens, read only when the agent opens those files.

What are the alternatives to Position Sizing?

Skills that share tags, products or a category with Position Sizing: Volatility Percentile Strategy (HKUDS/Vibe-Trading, 35k stars), Fix (alirezarezvani/claude-skills, 28k stars), Agent Trading Predictor (ruvnet/ruflo, 74k stars) and LLM Trading Agent Security (affaan-m/ECC, 275k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Position Sizing?

agiprolabs (a GitHub user) maintains it in agiprolabs/claude-trading-skills, which has 410 GitHub stars. The repository holds 68 skills in this directory. The repository was last updated on September 3, 2026.

Source: agiprolabs/claude-trading-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.