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.
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""
|
|
Database model for parsed SEC 8-K filing events.
|
|
Each row represents one Item extracted from an 8-K primary document.
|
|
"""
|
|
|
|
from datetime import datetime, timezone
|
|
import uuid
|
|
|
|
from sqlalchemy import Column, String, Text, Index
|
|
from sqlalchemy.dialects.postgresql import UUID, TIMESTAMP, JSON
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class SECFilingEvent(Base):
|
|
__tablename__ = "sec_filing_events"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
ticker = Column(String(10), nullable=False, index=True)
|
|
accession_number = Column(String(30), nullable=False, index=True)
|
|
form_type = Column(String(20), nullable=False)
|
|
filing_date = Column(TIMESTAMP(timezone=True), nullable=False)
|
|
item_number = Column(String(10), nullable=False) # e.g. "8.01"
|
|
event_type = Column(String(50), nullable=False) # e.g. "other_material_event"
|
|
title = Column(String(512)) # Item title from document
|
|
summary = Column(Text) # Extracted text content (truncated)
|
|
content_source = Column(String(20)) # "primary_doc" or "exhibit"
|
|
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__ = (
|
|
Index("idx_filing_events_ticker_date", "ticker", "filing_date"),
|
|
Index("idx_filing_events_ticker_type", "ticker", "event_type"),
|
|
Index("idx_filing_events_date", "filing_date"),
|
|
)
|