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.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""
|
|
FINRA RegSHO Short Sale Volume model
|
|
"""
|
|
|
|
from sqlalchemy import Column, String, Float, Index, UniqueConstraint
|
|
from sqlalchemy.dialects.postgresql import UUID, TIMESTAMP
|
|
from datetime import datetime, timezone
|
|
import uuid
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class FinraShortVolume(Base):
|
|
__tablename__ = "finra_short_volume"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
date = Column(TIMESTAMP(timezone=True), nullable=False)
|
|
symbol = Column(String(10), nullable=False, index=True)
|
|
short_volume = Column(Float, nullable=False)
|
|
short_exempt_volume = Column(Float, default=0)
|
|
total_volume = Column(Float, nullable=False)
|
|
market = Column(String(10), nullable=True) # e.g. "B", "Q", "N"
|
|
short_ratio = Column(Float, nullable=True) # short_volume / total_volume
|
|
created_at = Column(
|
|
TIMESTAMP(timezone=True), default=lambda: datetime.now(timezone.utc)
|
|
)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("symbol", "date", "market", name="uq_finra_short_volume"),
|
|
Index("idx_finra_symbol_date", "symbol", "date"),
|
|
Index("idx_finra_date", "date"),
|
|
)
|