Skip to main content

Entry points

These are the top-level entry points (not in scripts/):

scripts/

onboarding.py

First-time setup wizard. Run once.
  • Prompts for .env credentials
  • Pulls latest models from HF Hub
  • Runs risk questionnaire (6 questions → profile 1–5)
  • Runs first weekly optimize

weekly_optimize.py

Autonomous 13-phase weekly pipeline.
Profiles: steady_income (1), conservative (2), balanced (3), growth (4), aggressive (5).

retrain.py

Standalone retrain — always trains all 4 models together to prevent feature/risk mismatches.

sweep.py

Unified config parameter sweep. Replaces the old sweep_signal.py and sweep_pos_model.py.
Broker params (spread, leverage) are loaded from the live MT5 API on each run; override with --spread / --leverage.

optimize_loop.py

Iterative optimization loop — runs SHAP → tune → retrain → OOS in a loop, committing only when score improves by ≥ 2%.
Feature dropping (--drop-threshold) is disabled by default (0.0). Near-zero SHAP at train time does not mean a feature is useless — news and session features score near-zero during training but carry live signal at inference time. Do not enable dropping without careful review.
_PKL_FILES must include .onnx files alongside their .pkl counterparts. If ONNX files are omitted from the snapshot, rollback restores the pkl scaler but leaves a stale ONNX — the predictor then uses mismatched models silently.

config_sync.py

Shared config authority helpers (imported by other scripts — not a standalone CLI). Validates config.json and ml_config.json on startup and exposes sync_generated_configs().

notify.py

Send a manual Telegram notification.

ml/hf_hub.py

Hugging Face Hub model management.

Go binary scripts

These scripts are used when building the compiled Go binary. They are not needed for the Python bot.

scripts/export_scalers.py

Exports fitted scikit-learn StandardScaler objects from .pkl to JSON for Go inference.
Outputs (in models/):
  • ensemble_scaler.json
  • position_scaler.json
  • risk_scaler.json
  • sltp_scaler.json
Run after every retrain before packing the Go binary.

scripts/export_onnx_regression.py

Converts LightGBM regression models (risk and SLTP) from their native .txt format to ONNX using onnxmltools.
Outputs (in models/):
  • risk_lgb.onnx — 7 features
  • sltp_sl_lgb.onnx — market features + signal_direction
  • sltp_tp_lgb.onnx — same
Includes a smoke test with onnxruntime after each export.
Ensemble and position ONNX files are exported automatically by the Python trainer. Only risk and SLTP need this script.

scripts/pack_embedded.sh

Copies model files and configs into internal/embedded/ for Go’s //go:embed. Must be run before every go build.
What it copies:
  • models/*.onnxinternal/embedded/models/
  • models/*_scaler.json, models/*_metadata.jsoninternal/embedded/models/
  • ml_config.json, strategy_params.jsoninternal/embedded/
  • license.json (if --license) → internal/embedded/license.json

cmd/licgen — license generator

A separate binary the owner builds to generate signed license.json files. Never ship licgen to customers.
Options:

Go binary — full build sequence

After make train or python scripts/retrain.py: