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.
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
"""
|
|
SC 13D / 13G Activist Ownership Events model
|
|
"""
|
|
|
|
from datetime import datetime, timezone
|
|
import uuid
|
|
|
|
from sqlalchemy import Column, String, Float, Boolean, Index, Text, UniqueConstraint
|
|
from sqlalchemy.dialects.postgresql import UUID, TIMESTAMP
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class ActivistOwnershipEvent(Base):
|
|
__tablename__ = "activist_ownership_events"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
symbol = Column(String(10), nullable=False)
|
|
issuer_cik = Column(String(20), nullable=False)
|
|
filer_cik = Column(String(20), nullable=False)
|
|
filer_name = Column(String(500), nullable=False)
|
|
accession_number = Column(String(30), nullable=False)
|
|
form_type = Column(String(20), nullable=False) # SC 13D, SC 13G, SC 13D/A, SC 13G/A
|
|
filing_date = Column(TIMESTAMP(timezone=True), nullable=False)
|
|
is_amendment = Column(Boolean, nullable=False, default=False)
|
|
ownership_pct = Column(Float, nullable=True)
|
|
shares_owned = Column(Float, nullable=True)
|
|
change_pct = Column(Float, nullable=True)
|
|
# index_only | parsed | parse_failed
|
|
parse_status = Column(String(20), nullable=False, default="index_only")
|
|
filing_url = Column(Text, nullable=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__ = (
|
|
UniqueConstraint(
|
|
"accession_number", "filer_cik",
|
|
name="uq_activist_event",
|
|
),
|
|
Index("idx_activist_sym_date", "symbol", "filing_date"),
|
|
Index("idx_activist_filer_issuer", "filer_cik", "issuer_cik", "filing_date"),
|
|
Index("idx_activist_filing_date", "filing_date"),
|
|
)
|