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:
Celes Renata
2026-04-30 05:49:38 +00:00
parent fa18b1a7c2
commit 5209cc522e
3 changed files with 98 additions and 9 deletions
+3 -1
View File
@@ -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