# src/portfolio/allocation.py
from dataclasses import dataclass
from typing import Dict


@dataclass
class Allocation:
    """
    Define cómo se reparte el riesgo entre estrategias.
    Los pesos deben sumar 1.0
    """
    weights: Dict[str, float]

    def validate(self):
        total = sum(self.weights.values())
        if abs(total - 1.0) > 1e-6:
            raise ValueError(f"Allocation weights must sum to 1. Got {total}")
