"""Pydantic response shapes for the JSON API."""
from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel


class QuoteOut(BaseModel):
    symbol: str
    source: str
    label: str
    group_name: str
    price: float | None
    currency: str | None
    as_of: str | None
    changes: dict | None
    fetched_at: datetime
    error: str | None = None


class HeadlineOut(BaseModel):
    source: str
    category: str
    title: str
    url: str
    published_at: datetime
    tags: list[str] | None = None   # populated by news_tagging; null = pending


class JobStatus(BaseModel):
    name: str
    last_started: datetime | None = None
    last_finished: datetime | None = None
    status: str | None = None
    error: str | None = None
    items_written: int | None = None


class HealthOut(BaseModel):
    db: str  # "ok" | "down"
    jobs: list[JobStatus]


class StrategicLogOut(BaseModel):
    generated_at: datetime
    model: str
    anchor_date: str | None
    content: str
    prompt_tokens: int | None
    completion_tokens: int | None


# PositionOut / PortfolioSummary removed in Phase G — the server no
# longer holds positions; the browser computes P/L from /api/universe.
