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.
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
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.
Generated automatically alongside the JSON report. Contains:
Parameters summary
Calculation details for the active method
Constraints analysis (if any)
Final recommendation with shares, value, and risk
Reports are saved to reports/ with filenames position_sizer_YYYY-MM-DD_HHMMSS.json and .md.
Resources
references/sizing_methodologies.md: Comprehensive guide to Fixed Fractional, ATR-based, and Kelly Criterion methods with examples, comparison table, and risk management principles
scripts/position_sizer.py: Main calculation script (CLI interface)
Key Principles
Survival first: Position sizing is about surviving losing streaks, not maximizing winners
The 1% rule: Default to 1% risk per trade; never exceed 2% without exceptional reason
Default to whole shares: Existing workflows remain integer-share by default
Floor, never round up: Whole-share mode floors to an integer; fractional mode floors to the requested precision so risk and concentration budgets are not exceeded
Strictest constraint wins: When multiple limits apply, the tightest one determines final size
Half Kelly: Never use full Kelly in practice; half Kelly captures 75% of growth with far less risk
Portfolio heat: Total open risk should not exceed 6-8% of account equity
Intraday rules are broker-specific: FINRA replaced the old pattern-day-trader day-count and $25,000 minimum-equity requirements with intraday margin standards effective 2026-06-04, with broker phase-in allowed through 2027-10-20. Check the broker's current rules before repeated same-day trading in a margin account.
Asymmetry of losses: A 50% loss requires a 100% gain to recover; size accordingly