"""Core types: Signal, SignalBundle, Direction, OHLCV."""

from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from typing import Any


class Direction(Enum):
    """Signal direction: long or short."""

    LONG = "long"
    SHORT = "short"


@dataclass(frozen=True)
class OHLCV:
    """Single bar: open, high, low, close, volume."""

    open: float
    high: float
    low: float
    close: float
    volume: float


@dataclass(frozen=True)
class Signal:
    """Structured signal from a generator: direction, strength, metadata."""

    direction: Direction
    strength: float  # in [0, 1]
    timestamp: Any  # last bar timestamp or equivalent
    source: str  # generator name
    metadata: dict[str, Any]  # e.g. indicator values, separation %, band levels

    def __post_init__(self) -> None:
        if not 0 <= self.strength <= 1:
            raise ValueError("strength must be in [0, 1]")


@dataclass(frozen=True)
class SignalBundle:
    """Container for multiple signals on the same bar."""

    symbol: str
    timestamp: Any
    signals: tuple[Signal, ...]
