from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, Field


class WatchInput(BaseModel):
    identifier: str = Field(min_length=1, max_length=40)


class WatchRemarkInput(BaseModel):
    remark: str = Field(max_length=500)


class NoteInput(BaseModel):
    trade_date: str
    code: str = Field(default="", max_length=12)
    stock_name: str = Field(default="", max_length=40)
    summary: str = Field(default="", max_length=500)
    content: str = Field(default="", max_length=5000)
    plan: str = Field(default="", max_length=2000)


class TradeInput(BaseModel):
    id: int | None = Field(default=None, gt=0)
    trade_date: str
    code: str = Field(min_length=6, max_length=12)
    name: str = Field(min_length=1, max_length=40)
    action: Literal["buy", "sell", "add", "trim", "watch"]
    price: float = Field(ge=0, le=1_000_000)
    quantity: int = Field(default=0, ge=0, le=100_000_000)
    position_pct: float | None = Field(default=None, ge=0, le=100)
    pnl_amount: float | None = Field(default=None, ge=-1e12, le=1e12)
    pnl_pct: float | None = Field(default=None, ge=-1000, le=10000)
    emotion: Literal["calm", "confident", "hesitant", "anxious", "impulsive"]
    tags: list[str] = Field(default_factory=list, max_length=8)
    thesis: str = Field(default="", max_length=2000)
    execution: str = Field(default="", max_length=2000)


class AlertInput(BaseModel):
    title: str = Field(min_length=1, max_length=80)
    remind_date: str
    code: str = Field(default="", max_length=12)
    content: str = Field(default="", max_length=500)


class AssistantInput(BaseModel):
    trade_date: str
    question: str = Field(min_length=1, max_length=2000)
