Skip to content

Commit d8ef90c

Browse files
committed
refactor: align trading schemas with probabilistic paper trading system
1 parent eb0b46d commit d8ef90c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

backend/schemas/trading.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from pydantic import BaseModel
2+
from datetime import datetime
3+
from typing import Optional
4+
5+
6+
# ----------------------------
7+
# MODEL OUTPUT (Signal)
8+
# ----------------------------
9+
10+
class TradeSignal(BaseModel):
11+
"""
12+
Output of the ML system.
13+
This is NOT a trade.
14+
"""
15+
symbol: str
16+
17+
p_up: float
18+
expected_return: float
19+
uncertainty: float
20+
21+
model_version: Optional[str] = None
22+
timestamp: datetime
23+
24+
25+
# ----------------------------
26+
# EXECUTED TRADE (Paper Only)
27+
# ----------------------------
28+
29+
class ExecutedTrade(BaseModel):
30+
"""
31+
Result of execution logic.
32+
Generated only after passing risk & confidence checks.
33+
"""
34+
symbol: str
35+
side: str # BUY or SELL
36+
37+
quantity: int
38+
execution_price: float
39+
40+
signal_p_up: float
41+
signal_uncertainty: float
42+
43+
timestamp: datetime
44+
45+
46+
# ----------------------------
47+
# PORTFOLIO SNAPSHOT (Optional)
48+
# ----------------------------
49+
50+
class PortfolioSnapshot(BaseModel):
51+
"""
52+
Lightweight portfolio state for analytics & audits.
53+
"""
54+
cash: float
55+
positions: dict[str, int]
56+
total_value: float
57+
timestamp: datetime

0 commit comments

Comments
 (0)