position-sizing
Skill36 starsChanged 8 months agoMITView on GitHub
Calculate optimal position sizes for NSE/BSE equity trades using fixed fractional, ATR-based, and Kelly criterion methods. Includes portfolio constraints and leverage adjustments.
- Installs packages
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
2
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
- Very specific: line 18
No dependencies required. Works with manually provided prices.
- Distinctive: line 102
If a position would breach a constraint, reduce size until it fits.
- Distinctive: line 106
When using margin/leverage, the math changes because losses are amplified:
“Common” is measured: kept by at least 6 in 10 of the 7 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 Sizing
Position sizing is how you survive. The goal: risk a small, consistent percentage of capital per trade so that no single loss can cripple your account.
Prerequisites
No dependencies required. Works with manually provided prices. Enhanced with Groww MCP (live price, ATR, portfolio) or yfinance (pip install yfinance).
Data Needed
- Account size: Total trading capital (ask user if not known)
- Current price:
get_quotes_and_depthfrom Groww, or user-provided - ATR(14):
get_historical_technical_indicatorsfrom Groww, or calculate from candle data - Existing positions:
get_equity_portfolio_holdingsto check concentration (optional)
Method 1: Fixed Fractional (Default)
This is the go-to method. Simple, robust, works for everyone.
Risk per trade = Account size × Risk%
Shares = Risk per trade ÷ (Entry price - Stop-loss price)
Capital required = Shares × Entry priceRisk% guidelines:
| Situation | Risk% |
| Normal (no leverage) | 1-2% |
| With 2x leverage | 0.5-1% |
| With 3-4x leverage | 0.25-0.5% |
| High conviction trade | Up to 3% (rare) |
| New/uncertain setup | 0.5% |
Example
Account: Rs.10,00,000
Risk: 2% = Rs.20,000
Entry: Rs.1,800
Stop: Rs.1,700 (Rs.100 risk per share)
Shares: 20,000 ÷ 100 = 200 shares
Capital: 200 × 1,800 = Rs.3,60,000 (36% of account)Method 2: ATR-Based Sizing
Uses volatility to set the stop distance, then sizes accordingly.
Stop distance = ATR(14) × multiplier
Shares = Risk amount ÷ Stop distance| Market Condition | ATR Multiplier |
| Low volatility (ADX < 20) | 1.5× ATR |
| Normal volatility | 2.0× ATR |
| High volatility (ADX > 30) | 2.5× ATR |
This naturally sizes you smaller in volatile stocks and larger in calm ones.
Method 3: Kelly Criterion (Advanced)
For traders with a track record of at least 30 trades:
Kelly% = W - (1 - W) / R
W = historical win rate
R = average win / average loss
Use Half-Kelly (Kelly% ÷ 2) for real trading — full Kelly is too aggressive.| Win Rate | Avg W/L Ratio | Kelly% | Half-Kelly |
| 40% | 2.0 | 10% | 5% |
| 50% | 1.5 | 17% | 8% |
| 60% | 1.2 | 27% | 13% |
Portfolio Constraints
These are hard limits — never exceed them regardless of sizing method:
| Constraint | Limit |
| Single stock | Max 20% of portfolio |
| Single sector | Max 35% of portfolio |
| Total open risk | Max 6% of portfolio (sum of all position risks) |
| Correlated positions | Max 3 stocks in same sector simultaneously |
If a position would breach a constraint, reduce size until it fits.
Leverage Adjustment
When using margin/leverage, the math changes because losses are amplified:
Effective risk% = Risk% × Leverage
So: reduce your base risk% by dividing by leverage
At 3.74x leverage:
Normal risk: 2%
Adjusted risk: 2% ÷ 3.74 ≈ 0.5%
This keeps your effective risk at ~2%Output
Present position sizing as:
Position Size: XXX shares
Capital Required: Rs.X,XX,XXX
Risk Amount: Rs.X,XXX (X.X% of account)
Stop-Loss: Rs.XXX (X.X% below entry)
Portfolio Allocation: XX% of total capitalOther versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- agiprolabs/claude-trading-skills★ 366same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- SKE-Labs/agent-trading-skills★ 17same name
- brainbytes-dev/everything-claude-trading★ 16same name
- Shubhamkumartrichy/claude-trading-skills-india★ 7same name
- IngAs8/ClaudeSkill★ 0same name
- Serennity007/claude-trading-skills-67★ 0same 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.
Used alongsideProjects with it also use mean-reversion, feature-engineering and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
agiprolabsSkillmean-reversion
Mean-reversion strategy tools including Hurst exponent, half-life estimation, z-score signals, ADF testing, and Ornstein-Uhlenbeck modeling
Also in 4 projects that use this
ffsshhttiikkSkillfeature-engineering
Machine learning feature engineering
Also in 3 projects that use this
MicrosoftSkillsentiment-analysis
Use when a director of product asks for the fictional sentiment split and recent excerpts.
Also in 3 projects that use this
In this repository8 other files it gives its agents.
- fibonacci-tradingSkill
- multi-timeframe-analysisSkill
- nse-trading-toolkitSkill
- risk-reward-ratioSkill
- rsi-divergenceSkill
- stop-loss-strategiesSkill
- technical-analysisSkill
- trailing-stopsSkill
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.

