"""Pydantic schemas for technical indicator endpoints."""

from __future__ import annotations

from datetime import date
from typing import Any, Literal

from pydantic import BaseModel, Field


class IndicatorRequest(BaseModel):
    """Query parameters for indicator computation."""

    start_date: date | None = None
    end_date: date | None = None
    period: int | None = None


class IndicatorResult(BaseModel):
    """Raw indicator values plus normalized score."""

    indicator_type: str
    values: dict[str, Any]
    score: float = Field(ge=0, le=100)
    bars_used: int


class IndicatorResponse(BaseModel):
    """Envelope-ready indicator response."""

    symbol: str
    indicator: IndicatorResult


class EMACrossResult(BaseModel):
    """EMA cross signal details."""

    short_ema: float
    long_ema: float
    short_period: int
    long_period: int
    signal: Literal["bullish", "bearish", "neutral"]


class EMACrossResponse(BaseModel):
    """Envelope-ready EMA cross response."""

    symbol: str
    ema_cross: EMACrossResult
