- shared/schemas/trading.py: OrderRequest, OrderResult, PositionInfo, AccountInfo, TradeSignal, TradeExecution, MarketSnapshot, SentimentContext - shared/schemas/news.py: RawArticle, ScoredArticle - shared/schemas/learning.py: TradeOutcomeSchema, WeightAdjustment - shared/schemas/auth.py: RegisterRequest, LoginRequest, TokenResponse - 49 schema tests covering validation constraints, serialization round-trips, required fields, and range checks
32 lines
727 B
Python
32 lines
727 B
Python
"""Learning domain Pydantic schemas."""
|
|
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TradeOutcomeSchema(BaseModel):
|
|
"""Represents the evaluated outcome of a closed trade."""
|
|
|
|
trade_id: UUID
|
|
hold_duration_seconds: float = Field(ge=0)
|
|
realized_pnl: float
|
|
roi_pct: float
|
|
was_profitable: bool
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class WeightAdjustment(BaseModel):
|
|
"""Represents a strategy weight change made by the learning engine."""
|
|
|
|
strategy_id: UUID
|
|
strategy_name: str
|
|
old_weight: float
|
|
new_weight: float
|
|
reason: str
|
|
reward_signal: float
|
|
timestamp: datetime
|
|
|
|
model_config = {"from_attributes": True}
|