You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""
|
|
Earnings Surprise model — quarterly EPS actual vs estimate
|
|
"""
|
|
|
|
from datetime import datetime, timezone
|
|
import uuid
|
|
|
|
from sqlalchemy import Column, String, Float, Index, UniqueConstraint
|
|
from sqlalchemy.dialects.postgresql import UUID, TIMESTAMP
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class EarningsSurprise(Base):
|
|
__tablename__ = "earnings_surprises"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
ticker = Column(String(10), nullable=False, index=True)
|
|
fiscal_date_ending = Column(TIMESTAMP(timezone=True), nullable=False)
|
|
reported_date = Column(TIMESTAMP(timezone=True), nullable=True)
|
|
reported_eps = Column(Float, nullable=True)
|
|
estimated_eps = Column(Float, nullable=True)
|
|
surprise = Column(Float, nullable=True)
|
|
surprise_percentage = Column(Float, nullable=True)
|
|
data_source = Column(String(50), default="ALPHA_VANTAGE")
|
|
|
|
created_at = Column(
|
|
TIMESTAMP(timezone=True), default=lambda: datetime.now(timezone.utc)
|
|
)
|
|
updated_at = Column(
|
|
TIMESTAMP(timezone=True),
|
|
default=lambda: datetime.now(timezone.utc),
|
|
onupdate=lambda: datetime.now(timezone.utc),
|
|
)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("ticker", "fiscal_date_ending", name="uq_earnings_surprise"),
|
|
Index("idx_earnings_ticker_date", "ticker", "fiscal_date_ending"),
|
|
Index("idx_earnings_reported_date", "reported_date"),
|
|
)
|