Automated (every Sunday 2am UTC)
scripts/weekly_optimize.py runs autonomously on the trading VM:
- Pre-flight integrity check
- Select risk profile (loads saved profile; prompts interactively on first run)
- Fresh data from MT5 API
- SHAP analysis
- Optuna tuning (signal + position)
- Retrain all models
- Parameter sweep (scoped to selected profile’s config ranges)
- Apply best config + profile safety limits
- OOS backtest
- Keep or rollback (2% improvement gate)
- Push models to R2
- Update
strategy_params.json+PERF_HISTORY.md - Git commit
- Dry-run smoke test
- Telegram notification with full report
The Phase 5 sweep only sees the first 70% of the OOS window. The final evaluation (Phase 7) uses the full OOS window. This 70/30 split prevents the sweep from picking configs that fit the OOS data rather than generalise. The split is skipped if the OOS window is shorter than 90 days.
The sweep is also scoped to your risk profile — it only tests parameter combinations within the profile’s risk and confidence bounds. Profile 1 never tests 3% risk configs; Profile 5 never tests 0.65+ confidence configs. See Risk profiles for the full table.
Your weekly checklist
Sunday — after the cron fires
Check the Telegram notification. It tells you:- Whether the run improved or reverted
- New Score vs previous Score
- What specifically changed (confidence, SL/TP multiplier, etc.)
- Whether any tech debt was addressed
Monday — performance review
Check live trading performance from the past week:low_confidence dominates: lower the threshold. If atr_below_min dominates: market is ranging — this is expected during low-volatility periods.
Wednesday — mid-week spot check
Quick one-liner to confirm everything is still running:As needed — when Score drops
If you notice live WR declining or a degradation Telegram alert fires:Manual sweeps via
scripts/sweep.py use the full OOS window. The automated weekly pipeline (weekly_optimize.py) applies a 70/30 split — the sweep only sees the first 70% of OOS data and the final evaluation uses all of it. If you want the same guard for manual sweeps, add --oos-end YYYY-MM-DD to your backtest_config.py calls to cap the sweep window.Intervention triggers
| Signal | Action |
|---|---|
| Telegram: weekly run reverted | Review log, optionally run manual loop |
| Live WR < 55% over 50 trades | performance_monitor.py --retrain |
| Live PF < 2.0 over 50 trades | Config sweep → if no improvement, retrain |
| Consecutive losses = circuit breaker limit | Bot pauses automatically. Review after 1 trading day |
| Telegram: HARD DRAWDOWN HALT (exit 99) | Bot stopped permanently. Review equity, update risk_profile.starting_balance_usd, restart manually |
| Score < 6.0 on latest OOS | Pause live trading, run full optimization |
| Score < 10.0 on latest OOS | Trigger manual optimization loop |
Log files to watch
| File | Check for |
|---|---|
logs/weekly.log | Weekly pipeline outcome |
logs/trades.csv | Win/loss streak, hold times |
blocked_signals.csv | Block reason distribution |
state.json | Circuit breaker counter |
models/optimize_log.json | Score history across runs |