Go-live gate: refuse unsafe live trading
Setting MODE=live alone no longer starts trading. check_live_ready requires an active risk limit, MAX_POSITION_PCT < 1.0, LIVE_CONFIRMATION exactly "I UNDERSTAND THE RISK", a minimum balance, and exchange credentials. Enforced in Runtime.start_many (both start paths) and surfaced at GET /api/live-check; the dashboard shows a banner and blocks the start buttons. Adds tests.
This commit is contained in:
1 parent
b60cddf13d
commit
0173e46cfb
10 files changed
+241
-1
No files matched your search
@@ -144,6 +144,22 @@ injects it on the handshake). If `API_TOKEN` is unset, `/api/ws` is as open as
|
||||
the rest of `/api`, which is fine for a trusted/private deployment but is the
|
||||
reason to set a token if the host is exposed.
|
||||
|
||||
## Going live
|
||||
|
||||
Setting `MODE=live` alone is **not** enough. `GET /api/live-check` (and the
|
||||
dashboard banner) validate a preflight before any live order can be placed; live
|
||||
trading is blocked unless *all* of these hold:
|
||||
|
||||
- at least one risk limit is active (`MAX_DAILY_LOSS`, `MAX_DRAWDOWN_PCT` or
|
||||
`MAX_TRADES_PER_DAY`);
|
||||
- `MAX_POSITION_PCT < 1.0` (a single position can never be the whole account);
|
||||
- `LIVE_CONFIRMATION` is exactly `I UNDERSTAND THE RISK`;
|
||||
- the starting balance is at least `MIN_LIVE_BALANCE`;
|
||||
- exchange API credentials are set.
|
||||
|
||||
A blocked live start returns `400` with the reasons, and the dashboard shows a
|
||||
banner listing them. Practise the kill switch in paper mode first.
|
||||
|
||||
## Multi-strategy
|
||||
|
||||
The **Strategies (multi)** panel runs several strategies at once, each with its
|
||||
@@ -193,6 +209,7 @@ Bundled strategies: `sma_cross`, `ema_cross`, `macd_trend`,
|
||||
| `POST` | `/api/bot/start` | Start a strategy |
|
||||
| `POST` | `/api/bot/start-many` | Start several strategies with per-strategy allocations |
|
||||
| `GET` | `/api/bot/status` | Per-strategy status for a multi-strategy run |
|
||||
| `GET` | `/api/live-check` | Go-live preflight (blockers for live trading) |
|
||||
| `POST` | `/api/bot/stop` | Stop the bot |
|
||||
| `POST` | `/api/bot/kill` | Kill switch: flatten + halt |
|
||||
| `POST` | `/api/backtest` | Backtest a strategy on historical candles |
|
||||
|
||||
Reference in new issue
Block a user