Files
signal-platform/app/models/fundamental.py
T
dennisthiessen 25364f8e99
Deploy / lint (push) Successful in 7s
Deploy / test (push) Successful in 1m11s
Deploy / deploy (push) Successful in 37s
Optimize signal read paths and enforce score invariants
2026-07-11 13:36:59 +02:00

32 lines
1.2 KiB
Python

from datetime import date, datetime
from sqlalchemy import Date, DateTime, Float, ForeignKey, Text, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.database import Base
class FundamentalData(Base):
__tablename__ = "fundamental_data"
__table_args__ = (
UniqueConstraint("ticker_id", name="uq_fundamental_data_ticker"),
)
id: Mapped[int] = mapped_column(primary_key=True)
ticker_id: Mapped[int] = mapped_column(
ForeignKey("tickers.id", ondelete="CASCADE"), nullable=False
)
pe_ratio: Mapped[float | None] = mapped_column(Float, nullable=True)
revenue_growth: Mapped[float | None] = mapped_column(Float, nullable=True)
earnings_surprise: Mapped[float | None] = mapped_column(Float, nullable=True)
market_cap: Mapped[float | None] = mapped_column(Float, nullable=True)
next_earnings_date: Mapped[date | None] = mapped_column(Date, nullable=True)
fetched_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False
)
unavailable_fields_json: Mapped[str] = mapped_column(
Text, nullable=False, default="{}"
)
ticker = relationship("Ticker", back_populates="fundamental_data")