feat: pydantic schemas for all service message types
- 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
This commit is contained in:
parent
72cb1b6fe5
commit
c8277e301e
11 changed files with 889 additions and 0 deletions
32
shared/schemas/learning.py
Normal file
32
shared/schemas/learning.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"""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}
|
||||
Loading…
Add table
Add a link
Reference in a new issue