Repository layout
The repo is a Turborepo monorepo. The Python bot lives at the root; the website and shared design system are underapps/ and packages/.
Monorepo commands
The three-file rule
Any ML feature change touches exactly three files:ml/feature_engineering.pyβ add the feature computationml_config.jsonβfeaturesarray β add the name in the correct position- Retrain all 4 models β Signal, Position, SLTP, Risk (in that order)
models/model_compat.json file stores a hash of the feature list. On startup, EnsemblePredictor verifies the hash against the current ml_config.json. A mismatch raises ModelCompatibilityError immediately.
Strict training order
Models must always be trained in this order:
Training out of order produces either import errors or silent data contamination in the Risk modelβs training labels.
Backtester / live parity
backtest/run.py must always mirror trading/bot.py. Every change to execution logic in the bot must be reflected in the backtester, and vice versa.
Key parity invariants:
- Same feature engineering (
ml/feature_engineering.py) - Same model inference chain (calibrated pkl β ONNX β raw pkl)
- Same position sizing formula
- Same equity-aware SL cap
- Same circuit breakers and gates
- Same position model evaluation timing
Lane discipline
The codebase has two clearly separated lanes:
Clients should never retrain. The live trading host should stay simple β it does not need a GPU or the full ML dependency stack (just
pip install -r requirements.txt is fine).
Go binary β embedded asset system
The Go binary uses Goβs//go:embed directive to bake all ML models, scalers, and configs into the compiled binary at build time. The scripts/pack_embedded.sh script copies the necessary files into internal/embedded/ before each build.
models/ directory, Hugging Face Hub access, or any Python tooling. See Go binary for the full build and license reference.
Config files
Two config files govern all behavior:
Both are committed to git. When
weekly_optimize.py updates config.json, the change appears in git history. This makes every optimization run fully auditable.