Spaces:
Sleeping
Sleeping
File size: 936 Bytes
7b8993a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | """Pydantic models for alerts."""
from datetime import datetime
from typing import Literal, Optional
from pydantic import BaseModel, Field
class AlertConfig(BaseModel):
"""Alert configuration model."""
enabled: bool = True
positive_threshold: float = Field(0.1, description="Alert when FR > this value (%)")
negative_threshold: float = Field(-0.1, description="Alert when FR < this value (%)")
volume_spike_multiplier: float = Field(2.0, description="Alert when volume > avg * this value")
class AlertItem(BaseModel):
"""Single alert item."""
symbol: str
alert_type: Literal["high_positive_fr", "high_negative_fr", "volume_spike"]
value: float
threshold: float
message: str
timestamp: datetime
class AlertCheckResponse(BaseModel):
"""Response model for alert check endpoint."""
success: bool = True
alerts: list[AlertItem]
total_alerts: int
checked_at: datetime
|