Before you change anything
- Read
AGENTS.mdβ it is the canonical shared context for all contributors and agents - Check
docs/for the relevant page before relying on memory - Read the affected source files before changing behavior
- Make the smallest change that solves the request
Development workflow
Make your change
For ML changes: follow the three-file rule β
feature_engineering.py, ml_config.json, and retrain all 4 models.For execution changes: update both trading/bot.py and backtest/run.py.For config changes only: use scripts/sweep.py without retraining.Validate OOS
Invariants
These rules must never be violated:- Never reorder, add, or remove ML features without updating
ml_config.jsonand retraining all 4 models - Never change execution logic in
trading/bot.pywithout mirroring the change inbacktest/run.py - Training order is strict: Signal β Position β SLTP β Risk
- Never diverge
RISK_FEATURESacrossml/risk_trainer.py,ml/risk_predictor.py, andml_config.json - Never drop protected features (
is_news_near,news_minutes_away,news_count_today,is_news_risk_window,is_london_session,is_ny_session,is_asian_session) based on SHAP alone - Never run live trading before a dry-run
- Never train on Azure ML β training is local-only, GPU first, CPU fallback
Using Claude Code agents
For multi-step optimization tasks, delegate to Claude Code viascripts/run_agent.sh:
TASK="..." variable form. Avoid multiline shell continuations for TASK.
If using claude -p --output-format stream-json, include --verbose.
Agent roles
| Agent | Invoke via | Purpose |
|---|---|---|
@novosky-optimizer | Claude Code | Full SHAP β Optuna β retrain β OOS loop |
@feature-engineer | Claude Code | Feature add/remove with validation |
@risk-tuner | Claude Code | Risk/execution param sweep without retraining |
@model-optimizer | Claude Code | Assigns task complexity and writes scope lock |
What to check before committing
-
python backtest.py --oos-only --no-chartpasses with equal or better score -
python trading.py --dryruns without errors for 3+ cycles -
ml_config.jsonandmodels/model_compat.jsonare in sync if features changed -
trading/bot.pyandbacktest/run.pyare in parity if execution logic changed -
RISK_FEATURESis consistent across all three risk files if risk features changed - New models pushed to HF Hub:
python ml/hf_hub.py --push
Roadmap and open work
Active priorities (as of April 2026):- Multi-account support β
--accountflag to run multiple profiles simultaneously - Multi-instrument β XAUUSD, EURUSD alongside BTCUSD
- Multi-datasource OHLCV β secondary data source fallback
- Broker-agnostic refactor β full
config/brokers.jsonregistry coverage
main. Include an OOS backtest result showing the change is neutral or positive before requesting a merge.