# src/risk/sizing/fixed.py

from .base import PositionSizer


class FixedPositionSizer(PositionSizer):
    """
    Usa siempre un porcentaje fijo del capital disponible.
    """

    def __init__(self, capital_fraction: float = 1.0):
        if not 0 < capital_fraction <= 1:
            raise ValueError("capital_fraction debe estar entre 0 y 1")

        self.capital_fraction = capital_fraction

    def calculate_size(
        self,
        capital: float,
        entry_price: float,
        stop_price=None,
        volatility=None,
    ) -> float:
        notional = capital * self.capital_fraction
        units = notional / entry_price
        return units
