Logotipo de Position Sizing

Position Sizing

Comunidad
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.

Descripción general

Editornimadorostkar
RepositorioClaude-Skills-collection
Nombre de la habilidadposition-sizing
Estrellas
34
Forks
4
Archivos incluidos
Solo instrucciones
LicenciaMIT
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando la petición encaja con la habilidad.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Todo en las instrucciones

    Todo lo que necesita el modelo está en las instrucciones: no hay archivos adicionales que sincronizar.

  • Código abierto

    Publicada por nimadorostkar en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Position Sizing en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/nimadorostkar/Claude-Skills-collection/tree/main/skills/finance/position-sizing
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

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
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Position Sizing en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición encaja con la habilidad, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Position Sizing automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Position Sizing no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición que encaja con la habilidad, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

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.

Preguntas frecuentes

¿Qué hace la habilidad de IA 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.

¿Por qué usar Position Sizing en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Position Sizing está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Position Sizing en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/nimadorostkar/Claude-Skills-collection/tree/main/skills/finance/position-sizing. TypingMind lee el archivo SKILL.md de esa carpeta e instala su contenido como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Position Sizing?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Position Sizing?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Position Sizing con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Position Sizing?

Sí. nimadorostkar la ha publicado en GitHub bajo la licencia MIT. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver el directorio

Crea ya tu propio espacio de trabajo con IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇