feat: enhanced paper trading reset with capital and reserve controls
- Add initial capital input (toggle between broker balance or custom amount) - Add reserve/active pool split slider (0-50%, default 20%) - Backend accepts reserve_pct in reset request body - Note in UI that Alpaca balance reset requires Alpaca dashboard - Confirmation dialog shows exact capital and split being applied
This commit is contained in:
@@ -68,6 +68,7 @@ class CapitalRequest(BaseModel):
|
||||
"""Body for POST /api/trading/reset."""
|
||||
|
||||
initial_capital: float = 0.0
|
||||
reserve_pct: float | None = None
|
||||
|
||||
|
||||
class BacktestRequest(BaseModel):
|
||||
@@ -430,7 +431,8 @@ async def reset_paper_trading(body: CapitalRequest) -> dict[str, Any]:
|
||||
else:
|
||||
capital = 100_000.0
|
||||
|
||||
reserve_pct = engine.config.reserve_siphon_pct
|
||||
reserve_pct = body.reserve_pct if body.reserve_pct is not None else engine.config.reserve_siphon_pct
|
||||
reserve_pct = max(0.0, min(1.0, reserve_pct)) # clamp 0-100%
|
||||
reserve = capital * reserve_pct
|
||||
active = capital - reserve
|
||||
|
||||
|
||||
Reference in New Issue
Block a user