from pydantic import BaseModel
from typing import Optional, List, Literal

Direction = Literal["LONG", "SHORT"]

class Signal(BaseModel):
    ticker: str
    direction: Direction
    price: float          # aktueller Kurs
    entry: float
    stop: float
    tp1: float
    tp2: float
    crv: float
    win_chance: int       # in %
    status: Literal["Neu", "Aktiv", "Beendet"] = "Neu"
    comment: Optional[str] = None

class ScanResult(BaseModel):
    at: str
    kind: Literal["full", "live"]
    long_count: int
    short_count: int
    status: Literal["Erfolg", "Fehlgeschlagen"]
    duration_ms: int
    error: Optional[str] = None

class TickerRow(BaseModel):
    ticker: str
    date: str
    price: float
    pct: float
    trend: Literal["Aufwärts","Seitwärts","Abwärts"]
    score: int
    rvol: float
    atrp: float
    last_scan: str
    result: Literal["Erfolg", "Fehlgeschlagen"]
    gap: bool
    data_quality: Literal["OK","Warnung"]
    note: Optional[str] = None
    signal_status: Optional[Literal["Neu","Aktiv","Beendet"]] = None

class Settings(BaseModel):
    score_min: float
    rvol_min: float
    atr_min: float
    atr_max: float
    crv_min: float
    live_interval_min: int
    cooldown_min: int
    live_scan_filters: List[tuple] = []  # [(field, op, value)]
