‹ 首页

position-sizing

@bhala-srinivash · 收录于 1 周前

Calculate optimal position sizes for NSE/BSE equity trades using fixed fractional, ATR-based, and Kelly criterion methods. Includes portfolio constraints and leverage adjustments. Use when the user asks: "how many shares to buy", "position size for [stock]", "how much to invest in [stock]", "calculate lot size", "risk per trade", or any question about how much capital to allocate to a trade. Also triggers on portfolio allocation and leverage sizing questions.

适合你,如果你在交易印度股票并需要科学计算买入数量

/ 下载安装
position-sizing.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add bhala-srinivash/nse-trading-skills/position-sizing
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- bhala-srinivash/nse-trading-skills/position-sizing
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify bhala-srinivash/nse-trading-skills/position-sizing
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
30GitHub stars
~894上下文体积 · 单文件
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · 03fa324

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
  1. Account size: Total trading capital (ask user if not known)
  2. Current price: get_quotes_and_depth from Groww, or user-provided
  3. ATR(14): get_historical_technical_indicators from Groww, or calculate from candle data
  4. Existing positions: get_equity_portfolio_holdings to 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 price

Risk% 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 capital
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。