feat: add Signal Pydantic schemas
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a64636f6ff
commit
01d6b007f6
53
backend/app/schemas/signal.py
Normal file
53
backend/app/schemas/signal.py
Normal file
@ -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
|
||||||
Loading…
x
Reference in New Issue
Block a user