feat: Add backtesting parameter sweep support and related functionality

This commit is contained in:
2026-06-02 08:44:10 +02:00
parent 8ef8dc801d
commit f612c8533a
6 changed files with 685 additions and 7 deletions
+15 -7
View File
@@ -104,7 +104,7 @@ Minimum `.env` values:
```env
APP_ENV=dev
APP_HOST=0.0.0.0
APP_PORT=8000
APP_PORT=9090
LOG_LEVEL=INFO
LOG_JSON=true
DUCKDB_PATH=./data/arbitrade.duckdb
@@ -132,8 +132,8 @@ python -m arbitrade.main
Health endpoints:
- HTML: `http://localhost:8000/`
- JSON: `http://localhost:8000/health`
- HTML: `http://localhost:9090/`
- JSON: `http://localhost:9090/health`
## Database
@@ -283,12 +283,12 @@ Set these in Coolify application settings:
- Build Command: leave empty.
- Install Command: leave empty.
- Start Command: leave empty unless you explicitly want to override the image default.
- Port: `8000`
- Port: `9090` (coolify uses `8000` internally)
### 3) Configure health check and networking
- Health Check Path: `/health`
- Exposed Port: `8000`
- Exposed Port: `9090`
- Use Coolify-generated domain or attach your own domain.
### 4) Configure persistent storage
@@ -305,7 +305,7 @@ Add runtime environment variables in Coolify (UI: Environment Variables):
- `APP_ENV=prod`
- `APP_HOST=0.0.0.0`
- `APP_PORT=8000`
- `APP_PORT=9090`
- `DUCKDB_PATH=/app/data/arbitrade.duckdb`
- `LOG_LEVEL=INFO`
- `LOG_JSON=true`
@@ -431,6 +431,12 @@ Run a deterministic replay backtest from a JSONL event stream:
python scripts/backtest_replay.py --events path\to\replay.jsonl --starting-balances USD=1000.0
```
Run parameter sweep with train/test split and promotion scoring:
```powershell
python scripts/backtest_sweep.py --events path\to\replay.jsonl --starting-balances USD=1000.0 --output ops/backtesting/parameter_sweep_results.json
```
Replay event format:
```json
@@ -447,7 +453,9 @@ Notes:
- Events are replayed in timestamp order.
- The replay engine reuses the production detector, pre-trade validation, trade limits, and execution sequencer.
- The simulated execution path applies configurable slippage and execution latency so reports include deterministic trade/miss statistics.
Latency baseline and threshold artifacts:
- Parameter sweep splits replay data into in-sample and out-of-sample windows, ranks configurations by out-of-sample score, and flags overfit via train/test generalization-gap checks.
- Sweep output persists ranked combinations and promotion-ready candidates for paper-trading canary promotion decisions.
- Latency baseline and threshold artifacts:
- `ops/performance/latency_baseline.json`
- `ops/performance/latency_thresholds.json`