position-sizer
Skill0 starsChanged 3 months agoMITView on GitHub
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 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- ntaffzii/Skill-Agentstheir own version, first seen Nov 25, 2026
- rgourley/quant-garagetheir own version, first seen Nov 1, 2026
- IngAs8/ClaudeSkilledited, first seen Sep 28, 2026
- Wind-Alice/AliceMarketedited, first seen Apr 28, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- Wind-Alice/AliceMarket★ 14794% same
- IngAs8/ClaudeSkill★ 094% same
Wrote their own version · 2
- rgourley/quant-garage★ 7same name
- ntaffzii/Skill-Agents★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository71 other files it gives its agents.
- backtest-expertSkill
- breadth-chart-analystSkill
- breakout-trade-plannerSkill
- canslim-screenerSkill
- contrarian-setup-gateSkill
- cot-contrarian-detectorSkill
- crypto-regime-analyzerSkill
- data-quality-checkerSkill
- dividend-growth-pullback-screenerSkill
- downtrend-duration-analyzerSkill
- drawdown-circuit-breakerSkill
- dual-axis-skill-reviewerSkill
- earnings-calendarSkill
- earnings-trade-analyzerSkill
- economic-calendar-fetcherSkill
- edge-candidate-agentSkill
- edge-concept-synthesizerSkill
- edge-hint-extractorSkill
- edge-pipeline-orchestratorSkill
- edge-signal-aggregatorSkill
- edge-strategy-designerSkill
- edge-strategy-reviewerSkill
- exposure-coachSkill
- finviz-screenerSkill
- ftd-detectorSkill
- futures-position-sizerSkill
- fxmacrodata-calendarSkill
- ibd-distribution-day-monitorSkill
- institutional-flow-trackerSkill
- kanchi-dividend-review-monitorSkill
- kanchi-dividend-sopSkill
- kanchi-dividend-us-tax-accountingSkill
- macro-regime-detectorSkill
- market-breadth-analyzerSkill
- market-environment-analysisSkill
- market-news-analystSkill
- market-top-detectorSkill
- mt5-robot-testerSkill
- news-reaction-failure-analyzerSkill
- options-strategy-advisorSkill
- pair-trade-screenerSkill
- parabolic-short-trade-plannerSkill
- pead-screenerSkill
- portfolio-managerSkill
- pre-trade-discipline-gateSkill
- residual-edge-analyzerSkill
- scenario-analyzerSkill
- sector-analystSkill
- signal-postmortemSkill
- skill-designerSkill
- skill-idea-minerSkill
- skill-integration-testerSkill
- stanley-druckenmiller-investmentSkill
- stockbee-20pct-studySkill
- stockbee-episodic-pivot-analyzerSkill
- stockbee-exhaustion-hammer-screenerSkill
- stockbee-momentum-burst-screenerSkill
- stockbee-setup-fluency-trainerSkill
- strategy-pivot-designerSkill
- technical-analystSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 10 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
ATR-Based: Use Average True Range to set volatility-adjusted stop distances
- Distinctive: line 16
All methods apply portfolio constraints (max position %, max sector %) and output a final recommended share count with full risk breakdown.
- Distinctive: line 29
No API keys required
- Distinctive: line 44
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 …
- Distinctive: line 48
Run the position sizing calculation:
- Very specific: line 99
Read references/sizing_methodologies.md to provide context on the chosen method, risk guidelines, and portfolio constraint best practices.
- Distinctive: line 103
If the user has not specified a single method, run multiple scenarios for comparison:
- Distinctive: line 110
Add constraints if the user has portfolio context:
- Distinctive: line 189
The 1% rule: Default to 1% risk per trade.
- Distinctive: line 192
Strictest constraint wins: When multiple limits apply, the tightest one determines final size
- Distinctive: line 193
Half Kelly: Never use full Kelly in practice.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 Nwhen 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 principlesscripts/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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

