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:
# 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 \
--account-size 1000 \
--entry 155 \
--stop 148.50 \
--risk-pct 1.0 \
--fractional \
--share-precision 4 \
--output-dir reports/
# ATR-Based
python3 skills/position-sizer/scripts/position_sizer.py \
--account-size 100000 \
--entry 155 \
--atr 3.20 \
--atr-multiplier 2.0 \
--risk-pct 1.0 \
--output-dir reports/
# Kelly Criterion (budget mode - no entry)
python3 skills/position-sizer/scripts/position_sizer.py \
--account-size 100000 \
--win-rate 0.55 \
--avg-win 2.5 \
--avg-loss 1.0 \
--output-dir reports/
# Kelly Criterion (shares mode - with entry/stop)
python3 skills/position-sizer/scripts/position_sizer.py \
--account-size 100000 \
--entry 155 \
--stop 148.50 \
--win-rate 0.55 \
--avg-win 2.5 \
--avg-loss 1.0 \
--output-dir reports/
Step 3: Load Methodology Reference
Read references/sizing_methodologies.md to provide context on the chosen method, risk guidelines, and portfolio constraint best practices.
Step 4: Calculate Multiple Scenarios
If the user has not specified a single method, run multiple scenarios for comparison:
- Fixed Fractional at 0.5%, 1.0%, and 1.5% risk
- ATR-based at 1.5x, 2.0x, and 3.0x multipliers
- Present a comparison table showing shares, position value, and dollar risk for each
Step 5: Apply Portfolio Constraints and Determine Final Size
Add constraints if the user has portfolio context:
python3 skills/position-sizer/scripts/position_sizer.py \
--account-size 100000 \
--entry 155 \
--stop 148.50 \
--risk-pct 1.0 \
--max-position-pct 10 \
--max-sector-pct 30 \
--current-sector-exposure 22 \
--output-dir reports/
Explain which constraint is binding and why it limits the position.
Step 6: Generate Position Report
Present the final recommendation including:
- Method used and rationale
- Exact share count and position value
- Dollar risk and percentage of account
- Stop-loss price
- Any binding constraints
- Risk management reminders (portfolio heat, loss-cutting discipline)
- Small-account reminders: fractional shares do not remove broker minimums, spread/slippage, commissions/fees, margin limits, borrow availability, or day-trading controls
Output Format
JSON Report
{
"schema_version": "1.0",
"mode": "shares",
"parameters": {
"entry_price": 155.0,
"account_size": 100000,
"stop_price": 148.50,
"risk_pct": 1.0
},
"calculations": {
"fixed_fractional": {
"method": "fixed_fractional",
"shares": 153,
"risk_per_share": 6.50,
"dollar_risk": 1000.0,
"stop_price": 148.50
},
"atr_based": null,
"kelly": null
},
"constraints_applied": [],
"final_recommended_shares": 153,
"final_position_value": 23715.0,
"final_risk_dollars": 994.50,
"final_risk_pct": 0.99,
"binding_constraint": null
}
Markdown Report
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
1---2name: position-sizer3description: 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.4---56# Position Sizer78## Overview910Calculate the optimal number of shares to buy for a long stock trade based on risk management principles. Supports three sizing methods:1112- **Fixed Fractional**: Risk a fixed percentage of account equity per trade (default: 1%)13- **ATR-Based**: Use Average True Range to set volatility-adjusted stop distances14- **Kelly Criterion**: Calculate mathematically optimal risk allocation from historical win/loss statistics1516All 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.1718## When to Use1920- User asks "how many shares should I buy?"21- User wants to calculate position size for a specific trade setup22- User mentions risk per trade, stop-loss sizing, or portfolio allocation23- User asks about Kelly Criterion or ATR-based position sizing24- User has a small account where whole-share rounding would under-deploy a defined risk budget25- User wants to check if a position fits within portfolio concentration limits2627## Prerequisites2829- No API keys required30- Python 3.9+ with standard library only3132## Workflow3334### Step 1: Gather Trade Parameters3536Collect from the user:37- **Required**: Account size (total equity)38- **Mode A (Fixed Fractional)**: Entry price, stop price, risk percentage (default 1%)39- **Mode B (ATR-Based)**: Entry price, ATR value, ATR multiplier (default 2.0x), risk percentage40- **Mode C (Kelly Criterion)**: Win rate, average win, average loss; optionally entry and stop for share calculation41- **Optional constraints**: Max position % of account, max sector %, current sector exposure42- **Optional share mode**: Whole shares by default, or fractional shares with `--fractional --share-precision N` when supported by the broker4344If 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.4546### Step 2: Execute Position Sizer Script4748Run the position sizing calculation:4950```bash51# Fixed Fractional (most common)52python3 skills/position-sizer/scripts/position_sizer.py \53 --account-size 100000 \54 --entry 155 \55 --stop 148.50 \56 --risk-pct 1.0 \57 --output-dir reports/5859# Fractional shares for small accounts or high-priced stocks60python3 skills/position-sizer/scripts/position_sizer.py \61 --account-size 1000 \62 --entry 155 \63 --stop 148.50 \64 --risk-pct 1.0 \65 --fractional \66 --share-precision 4 \67 --output-dir reports/6869# ATR-Based70python3 skills/position-sizer/scripts/position_sizer.py \71 --account-size 100000 \72 --entry 155 \73 --atr 3.20 \74 --atr-multiplier 2.0 \75 --risk-pct 1.0 \76 --output-dir reports/7778# Kelly Criterion (budget mode - no entry)79python3 skills/position-sizer/scripts/position_sizer.py \80 --account-size 100000 \81 --win-rate 0.55 \82 --avg-win 2.5 \83 --avg-loss 1.0 \84 --output-dir reports/8586# Kelly Criterion (shares mode - with entry/stop)87python3 skills/position-sizer/scripts/position_sizer.py \88 --account-size 100000 \89 --entry 155 \90 --stop 148.50 \91 --win-rate 0.55 \92 --avg-win 2.5 \93 --avg-loss 1.0 \94 --output-dir reports/95```9697### Step 3: Load Methodology Reference9899Read `references/sizing_methodologies.md` to provide context on the chosen method, risk guidelines, and portfolio constraint best practices.100101### Step 4: Calculate Multiple Scenarios102103If the user has not specified a single method, run multiple scenarios for comparison:104- Fixed Fractional at 0.5%, 1.0%, and 1.5% risk105- ATR-based at 1.5x, 2.0x, and 3.0x multipliers106- Present a comparison table showing shares, position value, and dollar risk for each107108### Step 5: Apply Portfolio Constraints and Determine Final Size109110Add constraints if the user has portfolio context:111112```bash113python3 skills/position-sizer/scripts/position_sizer.py \114 --account-size 100000 \115 --entry 155 \116 --stop 148.50 \117 --risk-pct 1.0 \118 --max-position-pct 10 \119 --max-sector-pct 30 \120 --current-sector-exposure 22 \121 --output-dir reports/122```123124Explain which constraint is binding and why it limits the position.125126### Step 6: Generate Position Report127128Present the final recommendation including:129- Method used and rationale130- Exact share count and position value131- Dollar risk and percentage of account132- Stop-loss price133- Any binding constraints134- Risk management reminders (portfolio heat, loss-cutting discipline)135- Small-account reminders: fractional shares do not remove broker minimums, spread/slippage, commissions/fees, margin limits, borrow availability, or day-trading controls136137## Output Format138139### JSON Report140141```json142{143 "schema_version": "1.0",144 "mode": "shares",145 "parameters": {146 "entry_price": 155.0,147 "account_size": 100000,148 "stop_price": 148.50,149 "risk_pct": 1.0150 },151 "calculations": {152 "fixed_fractional": {153 "method": "fixed_fractional",154 "shares": 153,155 "risk_per_share": 6.50,156 "dollar_risk": 1000.0,157 "stop_price": 148.50158 },159 "atr_based": null,160 "kelly": null161 },162 "constraints_applied": [],163 "final_recommended_shares": 153,164 "final_position_value": 23715.0,165 "final_risk_dollars": 994.50,166 "final_risk_pct": 0.99,167 "binding_constraint": null168}169```170171### Markdown Report172173Generated automatically alongside the JSON report. Contains:174- Parameters summary175- Calculation details for the active method176- Constraints analysis (if any)177- Final recommendation with shares, value, and risk178179Reports are saved to `reports/` with filenames `position_sizer_YYYY-MM-DD_HHMMSS.json` and `.md`.180181## Resources182183- `references/sizing_methodologies.md`: Comprehensive guide to Fixed Fractional, ATR-based, and Kelly Criterion methods with examples, comparison table, and risk management principles184- `scripts/position_sizer.py`: Main calculation script (CLI interface)185186## Key Principles1871881. **Survival first**: Position sizing is about surviving losing streaks, not maximizing winners1892. **The 1% rule**: Default to 1% risk per trade; never exceed 2% without exceptional reason1903. **Default to whole shares**: Existing workflows remain integer-share by default1914. **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 exceeded1925. **Strictest constraint wins**: When multiple limits apply, the tightest one determines final size1936. **Half Kelly**: Never use full Kelly in practice; half Kelly captures 75% of growth with far less risk1947. **Portfolio heat**: Total open risk should not exceed 6-8% of account equity1958. **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.1969. **Asymmetry of losses**: A 50% loss requires a 100% gain to recover; size accordingly