""" Pydantic models for request/response validation """ from typing import Optional, List from pydantic import BaseModel class ClientDetails(BaseModel): client_id: str client_name: Optional[str] = None access_token: str availabel_balance: Optional[float] = 0.0 class OrderRequest(BaseModel): clients: List[str] # List of client names or IDs symbol: str exchange: str transaction_type: str # "BUY" or "SELL" order_type: str # "MARKET" or "LIMIT" product_type: str # "INTRA", "DELIVERY", "MTF", "NORMAL" client_quantities: Optional[dict] = None # { "client_name": quantity } quantity: Optional[int] = None lot: Optional[int] = None price: Optional[float] = 0.0 class HoldingData(BaseModel): tradingSymbol: str positionType: Optional[str] = None exchangeSegment: str productType: str costPrice: float netQty: int pnl: float account_holder: Optional[str] = None class SquareOffRequest(BaseModel): symbol: str segment: str # "fno", "etf", "equity" clients: List[dict] # [{"client": "name", "qty": 100}, ...] order_type: Optional[str] = "MARKET" # "MARKET", "LIMIT" price: Optional[float] = 0.0 transaction_type: Optional[str] = "SELL" # "BUY", "SELL" product_type: Optional[str] = None # "CASH", "MTF", "INTRADAY", etc. class OrderResponse(BaseModel): client: str success: bool response: Optional[dict] = None error: Optional[str] = None class BalanceResponse(BaseModel): name: str balance_inr: float class MetricsResponse(BaseModel): total_pnl: float active_scripts: int profitable_scripts: int