شعار Position Sizing

Position Sizing

المجتمع
nimadorostkar
position-sizing

Use when deciding how large a position to take. Covers fixed-fractional risk, volatility-based sizing, the Kelly criterion and why to fractionalize it, and portfolio concentration limits. Trigger on "how much should i put in this trade", "how many shares should i buy", "should i use kelly sizing". Do not use for account-level drawdown limits and pre-trade rules — see the risk-management skill.

نظرة عامة

الناشرnimadorostkar
المستودعClaude-Skills-collection
اسم المهارةposition-sizing
النجوم
34
التفريعات
4
الملفات المرفقة
تعليمات فقط
الترخيصMIT
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

  • مفتوحة المصدر

    نشرها nimadorostkar على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Position Sizing في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/nimadorostkar/Claude-Skills-collection/tree/main/skills/finance/position-sizing
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nimadorostkar/Claude-Skills-collection.git /tmp/Claude-Skills-collection
mkdir -p .claude/skills
cp -r /tmp/Claude-Skills-collection/skills/finance/position-sizing .claude/skills/position-sizing
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Position Sizing في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Position Sizing تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Position Sizing بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

Position Sizing

Purpose

Determine how much to risk on a single position, so that a losing streak is survivable and no single idea can end the account. Position sizing determines survival; entry selection determines returns. Survival comes first.

When to Use

  • Deciding how many shares or contracts to buy.
  • Setting a risk-per-trade policy.
  • Checking whether a position breaches concentration limits.
  • Reviewing why a drawdown was deeper than expected.

Capabilities

  • Fixed-fractional sizing from a stop distance.
  • Volatility-adjusted sizing using ATR.
  • Kelly criterion, and fractional Kelly in practice.
  • Concentration limits: per position, per sector, per correlated group.
  • Aggregate portfolio risk.

Inputs

  • Account equity.
  • Entry price and stop price (or an ATR and a multiplier).
  • Risk per trade, as a percentage of equity.
  • Existing exposure, including correlated positions.

Outputs

  • A share or contract count.
  • The dollar risk if the stop is hit, stated explicitly.
  • Whether the position breaches any limit.

Workflow

  1. Fix the risk per trade first — Typically 0.5% to 2% of equity. This is a policy decision made when calm, not a per-trade judgment made when excited.
  2. Determine the stop — At a level where the thesis is wrong, not at a level that produces a comfortable size. This is the discipline that everything else depends on.
  3. Size from the stop distance — Shares = (equity × risk%) / (entry − stop). A wider stop means a smaller position, not more risk.
  4. Check the concentration limits — Position size as a percentage of equity, sector exposure, and correlated exposure. A limit breached is a size reduced.
  5. Check the aggregate — Ten positions each risking 1% is 10% at risk if they are correlated and all stop out together. In a market-wide selloff, they will be.

Best Practices

  • Never widen a stop to justify a larger position. That inverts the entire logic: the stop defines the risk, and the size follows from it.
  • Correlated positions are one position. Five semiconductor names is one bet on semiconductors, and it should be sized as one.
  • Full Kelly is theoretically optimal and practically unusable: it produces enormous drawdowns, and it assumes you know your edge precisely. You do not. Half-Kelly or less is the practical range.
  • A 50% drawdown requires a 100% gain to recover. Sizing that permits deep drawdowns is not aggressive; it is arithmetically self-defeating.
  • Volatility-based sizing normalizes risk across instruments: a fixed dollar risk on a volatile stock and a quiet one produces very different position values, and that is correct.
  • Recalculate the size on the current equity, not on the starting equity. Sizing off a high-water mark after a drawdown compounds the damage.

Examples

Fixed-fractional sizing — the calculation that matters:

python
def position_size(
    equity: float,
    entry: float,
    stop: float,
    risk_pct: float = 0.01,
    max_position_pct: float = 0.20,
) -> PositionSize:
    if stop >= entry:
        raise ValueError("stop must be below entry for a long position")

    risk_dollars = equity * risk_pct
    risk_per_share = entry - stop
    shares = int(risk_dollars / risk_per_share)

    # The concentration limit binds independently of the risk limit. A very tight
    # stop can otherwise produce a position worth more than the account.
    max_shares_by_concentration = int((equity * max_position_pct) / entry)
    limited = shares > max_shares_by_concentration

    final = min(shares, max_shares_by_concentration)

    return PositionSize(
        shares=final,
        position_value=final * entry,
        dollar_risk=final * risk_per_share,
        pct_of_equity=(final * entry) / equity,
        limited_by_concentration=limited,
    )

# equity 100,000 | entry 50.00 | stop 47.50 | risk 1%
#   risk_dollars    = 1,000
#   risk_per_share  = 2.50
#   shares          = 400          -> position value 20,000 (20% of equity)
#   At the concentration cap exactly. A tighter stop of 49.50 would compute
#   2,000 shares ($100,000 — the whole account), and the cap correctly binds.

Kelly, and why it is fractionalized:

python
def kelly_fraction(win_rate: float, avg_win: float, avg_loss: float) -> float:
    """f* = p - q/b, where b is the win/loss ratio."""
    b = avg_win / abs(avg_loss)
    f = win_rate - (1 - win_rate) / b
    return max(0.0, f)

# A genuinely good strategy: 55% win rate, 1.5:1 payoff.
#   full Kelly     = 0.55 - 0.45/1.5 = 0.25  -> risk 25% of equity per trade
#
# Full Kelly on this strategy produces expected drawdowns exceeding 50% and
# assumes the 55% and the 1.5 are known exactly. They are estimates from a
# finite sample; if the true win rate is 50%, full Kelly is a losing bet.
#
#   half Kelly     = 12.5%   still aggressive
#   quarter Kelly  =  6.25%  the upper end of what most practitioners use
#
# Most professional risk budgets land between 0.5% and 2% — far below even
# quarter Kelly — because the edge estimate is uncertain and ruin is permanent.

Notes

  • Kelly maximizes the expected logarithmic growth rate given a known edge. The edge is never known; it is estimated from a sample, and the estimate is biased upward by the fact that you chose this strategy because it looked good. Fractionalize accordingly.
  • Correlation rises toward 1 in a crisis. A portfolio that appears diversified in normal conditions can be a single position at the worst moment. Size for the correlated case.
  • This is educational material about position-sizing methodology, not financial advice. Any real allocation decision depends on circumstances this skill cannot see.

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Position Sizing؟

Use when deciding how large a position to take. Covers fixed-fractional risk, volatility-based sizing, the Kelly criterion and why to fractionalize it, and portfolio concentration limits. Trigger on "how much should i put in this trade", "how many shares should i buy", "should i use kelly sizing". Do not use for account-level drawdown limits and pre-trade rules — see the risk-management skill.

لماذا تستخدم Position Sizing على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Position Sizing عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Position Sizing في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/nimadorostkar/Claude-Skills-collection/tree/main/skills/finance/position-sizing. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Position Sizing؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Position Sizing؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Position Sizing معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Position Sizing مجانية؟

نعم. نشرها nimadorostkar على GitHub بموجب ترخيص MIT. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇