from datetime import date as date_type from datetime import datetime from sqlalchemy import Date, DateTime, Float, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.database import Base class RegimeSnapshot(Base): """Daily snapshot of the AI/Tech regime-change index. One row per calendar date (unique). ``breakdown_json`` holds the full per-signal breakdown plus the raw inputs, so reads need no recomputation and the 7/30-day trend is just a query over ``total_score``. Decoupled from the rest of the platform: nothing reads this to gate or score trades. """ __tablename__ = "regime_snapshots" id: Mapped[int] = mapped_column(primary_key=True) date: Mapped[date_type] = mapped_column(Date, nullable=False, unique=True, index=True) total_score: Mapped[float] = mapped_column(Float, nullable=False) band: Mapped[str] = mapped_column(String(20), nullable=False) breakdown_json: Mapped[str] = mapped_column(Text, nullable=False) created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)