Position Sizingのロゴ

Position Sizing

コミュニティ
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.

概要

公開者Shubhamkumartrichy
リポジトリclaude-trading-skills-india
スキル名position-sizing
スター
57
フォーク
11
同梱ファイル
1
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    ShubhamkumartrichyがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Position Sizing」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Shubhamkumartrichy/claude-trading-skills-india/tree/main/skills/position-sizing
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでPosition Sizingを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にPosition Sizingを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Position Sizingは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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]

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「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...

TypingMindでPosition Sizingを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Position Sizingはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにPosition Sizingをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Shubhamkumartrichy/claude-trading-skills-india/tree/main/skills/position-sizingを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Position Sizingを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Position Sizingで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもPosition Sizingを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Position Sizing」は無料ですか?

はい。ShubhamkumartrichyがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇