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.
67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
"""
|
|
Universe screening schemas for backtesting universe construction
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class UniverseSnapshotItem(BaseModel):
|
|
ticker: str
|
|
name: Optional[str] = None
|
|
market_cap: Optional[float] = None
|
|
close_price: Optional[float] = None
|
|
shares_outstanding: Optional[float] = None
|
|
sector: Optional[str] = None
|
|
industry: Optional[str] = None
|
|
exchange: Optional[str] = None
|
|
snapshot_date: Optional[datetime] = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class UniverseScreenResponse(BaseModel):
|
|
stocks: List[UniverseSnapshotItem]
|
|
total_count: int
|
|
page: int
|
|
page_size: int
|
|
total_pages: int
|
|
snapshot_date: Optional[str] = None
|
|
filters_applied: Dict[str, Any] = {}
|
|
metadata: Dict[str, Any] = {}
|
|
|
|
|
|
class TickerRegistryItem(BaseModel):
|
|
ticker: str
|
|
name: Optional[str] = None
|
|
sector: Optional[str] = None
|
|
industry: Optional[str] = None
|
|
exchange: Optional[str] = None
|
|
cik: Optional[str] = None
|
|
is_active: bool = True
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class RegistryResponse(BaseModel):
|
|
tickers: List[TickerRegistryItem]
|
|
total_count: int
|
|
page: int
|
|
page_size: int
|
|
total_pages: int
|
|
|
|
|
|
class SnapshotBuildRequest(BaseModel):
|
|
tickers: Optional[List[str]] = Field(
|
|
None,
|
|
description="Specific tickers to build. Omit for all registry tickers.",
|
|
)
|
|
start_date: str = Field(..., description="Start date YYYY-MM-DD (e.g. 2015-01-01)")
|
|
end_date: str = Field(..., description="End date YYYY-MM-DD (e.g. 2025-12-01)")
|
|
force_rebuild: bool = Field(
|
|
False,
|
|
description="Delete existing snapshots for these tickers before rebuilding",
|
|
)
|