Add trailing stops and parameter sweeps
Trailing stops: strategies can pass trailing_stop_pct to enter_long/enter_short. advance_trailing_stop in app/engine/portfolio.py ratchets the stop with the price (up for longs, down for shorts) and never loosens; the engine persists the ratcheted level and the backtester applies the same logic. Position gains a trailing_stop_pct column (additive migration). momentum exposes it as a param. Parameter sweeps: app/backtest/sweep.py runs a cartesian grid through the same backtester and ranks by return minus max drawdown. POST /api/sweep plus a dashboard Parameter sweep panel.
This commit is contained in:
1 parent
d80e7b155e
commit
9dc00eba95
22 files changed
+575
-7
No files matched your search
@@ -10,6 +10,9 @@ drop in one Python file, run it, and watch positions and P&L live.
|
||||
- **Market data:** Binance public REST (no API key needed).
|
||||
- **Backtesting:** replay historical candles through the same strategy interface,
|
||||
with return/drawdown/win-rate/Sharpe metrics — so what you test is what runs.
|
||||
- **Parameter sweeps:** grid-search a strategy's params and rank the results.
|
||||
- **Trailing stops:** strategies can trail a stop with the price (never loosening),
|
||||
enforced identically in backtest, paper and live.
|
||||
|
||||
> **Paper trading is the default.** Live mode places real orders and is opt-in.
|
||||
> This is experimental software. Never trade more than you can afford to lose.
|
||||
@@ -182,6 +185,7 @@ Bundled strategies: `sma_cross`, `ema_cross`, `macd_trend`,
|
||||
| `POST` | `/api/bot/stop` | Stop the bot |
|
||||
| `POST` | `/api/bot/kill` | Kill switch: flatten + halt |
|
||||
| `POST` | `/api/backtest` | Backtest a strategy on historical candles |
|
||||
| `POST` | `/api/sweep` | Grid-sweep strategy params, ranked |
|
||||
| `GET` | `/api/positions` | Positions (with unrealized P&L when open) |
|
||||
| `GET` | `/api/orders` | Order history |
|
||||
| `GET` | `/api/events` | Activity log |
|
||||
|
||||
Reference in new issue
Block a user