Logo: Position Sizing

Position Sizing

Communautéit
Shubhamkumartrichy
position-sizing

Position sizing for Indian equity and F&O trades: fixed-fractional risk sizing with round-trip costs included, ATR-based stops, F&O lot rounding and margin checks, MTF/intraday leverage adjustment, gap-through-stop and circuit risk, Kelly from a trade journal, and portfolio limits. risk.py also covers R:R, trailing stops and journal statistics. Use when the user asks: "how many shares should I buy", "position size for X", "how many lots of NIFTY", "how much to invest", "risk per trade", "can I afford one lot", "Kelly criterion", "what's my win rate / expectancy", or any capital-allocation question.

Iwwersiicht

EditeurShubhamkumartrichy
Repositoryclaude-trading-skills-india
Skill-Nummposition-sizing
Stären
57
Forks
11
Matgeliwwert Dateien
1
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 1 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Shubhamkumartrichy huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Position Sizing an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/Shubhamkumartrichy/claude-trading-skills-india/tree/main/skills/position-sizing
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Shubhamkumartrichy/claude-trading-skills-india.git /tmp/claude-trading-skills-india
mkdir -p .claude/skills
cp -r /tmp/claude-trading-skills-india/skills/position-sizing .claude/skills/position-sizing
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Position Sizing an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Position Sizing automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Position Sizing net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Position Sizing

Sizing decides survival. Risk a small, fixed fraction of capital per trade so that a losing streak, which will happen, is survivable.

Calculator

bash
# Equity, structure stop
python3 scripts/risk.py size --capital 500000 --risk-pct 1 --entry 1450 --stop 1410
# Equity, ATR stop + gap-risk check for a midcap
python3 scripts/risk.py size --capital 500000 --risk-pct 1 --entry 1450 --atr 28 --atr-mult 2 --cap midcap
# NIFTY futures: lot rounding + margin
python3 scripts/risk.py size --capital 800000 --risk-pct 1 --entry 24950 --stop 24800 --lot-size 65 \
    --margin-per-lot 165000 --cost-pct 0.06
# MTF at 3x
python3 scripts/risk.py size --capital 300000 --risk-pct 1 --entry 820 --stop 790 --leverage 3
# Win rate / payoff / Kelly from your journal (date,symbol,side,entry,exit,stop,qty,charges | or pnl)
python3 scripts/risk.py journal trades.csv

--cost-pct is the round-trip cost as % of entry. Use about 0.25 for delivery, 0.05 for intraday, and 0.06 for index futures, or compute it exactly with trading-costs. Get margin per lot from the broker's margin calculator or the MCP margin tool, because SPAN changes daily.

Method 1: fixed fractional (default)

Risk budget = Capital × Risk%            (÷ leverage when using MTF/MIS margin)
Units       = Budget ÷ (|Entry − Stop| + cost per unit)
F&O         = floor(Units ÷ lot size) lots
SituationRisk % per trade
Normal swing/positional, no leverage0.5–1% (max 2%)
New or unproven setup0.25–0.5%
With MTF/MIS leveragebase risk ÷ leverage (see below)
F&O beginners0.5%, and only defined-risk structures
Total open risk across all positions≤ 6%

Why divide by leverage? The loss at the stop doesn't depend on leverage. But leverage lets a position grow beyond your cash, so a gap through the stop or a margin call hurts far more. risk.py --leverage therefore divides the risk budget by the leverage as a deliberate safety haircut. Pass --leverage 1 if you want the plain calculation.

Example: capital ₹10 lakh, 2% risk, entry ₹1,800, stop ₹1,700. Without costs that is 200 shares. With 0.25% round-trip costs, risk per share is ₹104.5, so 191 shares. That is ₹3.44 lakh, 34% of capital, which breaches the 20% single-stock cap, so cap at about 111 shares unless the user accepts the concentration.

Method 2: ATR-based stop distance

Stop = Entry − ATR(14) × k         k: 1.5 (calm, ADX<20) | 2.0 (normal) | 2.5 (volatile, ADX>30)

Volatile stocks automatically get smaller size. Get ATR from ta.py summary.

Method 3: Kelly (needs 30+ trades of history)

Kelly% = W − (1 − W) / R      W = win rate, R = avg win / avg loss

Kelly gives the fraction of capital to risk per trade, not to invest. Use at most half-Kelly and never more than 2%. risk.py journal computes W, R, profit factor, drawdown and Kelly from a CSV.

F&O specifics

  • One lot is the minimum unit. At end-October 2026 levels, one NIFTY lot (65 × ~23,050) is about ₹15 lakh notional and one BANKNIFTY lot (30 × ~54,700) about ₹16.4 lakh. If one lot at a sensible stop risks more than 1–2% of capital, the answer is don't trade futures. Use a defined-risk option spread, or trade the cash stock instead.
  • Option buying: the premium is the maximum loss. Size so that total premium at risk ≤ risk budget, or use a premium stop (for example, exit at −40%) and size on that.
  • Option selling: size on max loss (spreads) or a stress move (naked; 2–3× the expected move). Never size on margin alone.
  • Margin headroom: keep used margin ≤ 50% of capital. With --margin-per-lot, risk.py size caps lots at that limit automatically (--max-margin-pct changes it). Margins rise on volatility spikes, on expiry day (+2% ELM on shorts), and for stock F&O in expiry week (physical delivery).
  • 50:50 rule: at least half of F&O margin must be cash or cash-equivalent.

Indian risk overlays (always check)

  1. Gap-through-stop. --cap largecap|midcap|smallcap (3/5/10%) or --gap-pct shows the loss if price gaps beyond the stop. Results, global sell-offs and regulatory news gap Indian stocks overnight.
  2. Circuits. In stocks with 5% or 10% bands, a lower circuit can last days, and the stop never fills. Cut size so a two-day circuit run (2 × band) stays tolerable.
  3. Liquidity. Keep the position below about 1% of the stock's average daily traded value. SME and illiquid small caps need far smaller sizes.
  4. Correlation. Three private banks are effectively one position. Apply the sector limit.

Portfolio limits (hard)

ConstraintLimit
Single stock≤ 20% of capital (≤ 10% small caps)
Single sector≤ 35%
Total open risk (sum of stop distances)≤ 6%
Correlated names in one sector≤ 3
F&O margin used≤ 50% of capital

Output

Position: N shares / L lots (qty Q)
Entry ₹E | Stop ₹S (x% away, method) | Value ₹V (y% of capital) | Margin ₹M
Risk if stopped: ₹R (r% incl. costs) | Gap-through loss: ₹G (g%)
Notes: [caps applied, lot too big, leverage adjustment, liquidity]

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Position Sizing?

Position sizing for Indian equity and F&O trades: fixed-fractional risk sizing with round-trip costs included, ATR-based stops, F&O lot rounding and margin checks, MTF/intraday leverage adjustment, gap-through-stop and circuit risk, Kelly from a trade journal, and portfolio limits. risk.py also covers R:R, trailing stops and journal statistics. Use when the user asks: "how many shares should I buy", "position size for X", "how many lots of NIFTY", "how much to invest", "risk per trade", "can I afford one lot", "Kelly criterion", "what's my win rate / expectancy", or any capital-allocation q...

Firwat Position Sizing op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Position Sizing besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Position Sizing an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/Shubhamkumartrichy/claude-trading-skills-india/tree/main/skills/position-sizing an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Position Sizing benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Position Sizing benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Position Sizing domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Position Sizing gratis?

Jo. Shubhamkumartrichy huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇