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.
37 lines
1.6 KiB
Python
37 lines
1.6 KiB
Python
"""
|
|
Database model for SEC filings (8-K, 6-K, 20-F, 40-F, 10-K, 10-Q, etc.)
|
|
"""
|
|
|
|
from sqlalchemy import Column, String, JSON, Index, Text
|
|
from sqlalchemy.dialects.postgresql import UUID, TIMESTAMP
|
|
from datetime import datetime, timezone
|
|
import uuid
|
|
from app.core.database import Base
|
|
|
|
|
|
class SECFiling(Base):
|
|
__tablename__ = "sec_filings"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
ticker = Column(String(10), nullable=False, index=True)
|
|
cik = Column(String(20), nullable=False, index=True)
|
|
accession_number = Column(String(30), nullable=False, unique=True, index=True)
|
|
form_type = Column(String(20), nullable=False, index=True)
|
|
filing_date = Column(TIMESTAMP(timezone=True), nullable=False)
|
|
accepted_at = Column(TIMESTAMP(timezone=True))
|
|
primary_document = Column(String(256))
|
|
primary_document_url = Column(String(512))
|
|
filing_description = Column(String(512))
|
|
documents_json = Column(JSON) # Cached document list
|
|
parsed_status = Column(String(20), default="pending") # pending|succeeded|failed|skipped
|
|
items_json = Column(JSON) # Extracted item numbers, e.g. ["8.01", "9.01"]
|
|
indexed_at = Column(TIMESTAMP(timezone=True))
|
|
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_sec_filings_ticker_form", "ticker", "form_type"),
|
|
Index("idx_sec_filings_ticker_date", "ticker", "filing_date"),
|
|
Index("idx_sec_filings_cik_form", "cik", "form_type"),
|
|
)
|