From 01d6b007f68f71cbf32115da9a9e0162377cf66d Mon Sep 17 00:00:00 2001 From: zephyrdark Date: Thu, 19 Feb 2026 15:06:03 +0900 Subject: [PATCH] feat: add Signal Pydantic schemas Co-Authored-By: Claude Opus 4.6 --- backend/app/schemas/signal.py | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 backend/app/schemas/signal.py diff --git a/backend/app/schemas/signal.py b/backend/app/schemas/signal.py new file mode 100644 index 0000000..1892551 --- /dev/null +++ b/backend/app/schemas/signal.py @@ -0,0 +1,53 @@ +""" +Signal related Pydantic schemas. +""" +from datetime import date, datetime +from decimal import Decimal +from typing import Optional, List +from enum import Enum + +from pydantic import BaseModel + +from app.schemas.portfolio import FloatDecimal + + +class SignalType(str, Enum): + BUY = "buy" + SELL = "sell" + PARTIAL_SELL = "partial_sell" + + +class SignalStatus(str, Enum): + ACTIVE = "active" + EXECUTED = "executed" + EXPIRED = "expired" + + +class SignalResponse(BaseModel): + id: int + date: date + ticker: str + name: Optional[str] = None + signal_type: str + entry_price: Optional[FloatDecimal] = None + target_price: Optional[FloatDecimal] = None + stop_loss_price: Optional[FloatDecimal] = None + reason: Optional[str] = None + status: str + created_at: datetime + + class Config: + from_attributes = True + + +class ActivePosition(BaseModel): + ticker: str + name: Optional[str] = None + entry_date: date + entry_price: FloatDecimal + current_price: FloatDecimal + shares: int + stop_loss_price: FloatDecimal + target_price: FloatDecimal + pnl_percent: FloatDecimal + pnl_amount: FloatDecimal