Skip to main content

File overview

FilePurposeTracked in git
.envSecrets and external service credentialsNo
config.jsonRuntime trading behavior, risk profile, filtersYes
ml_config.jsonFeature list, model paths, labeling, training paramsYes
The onboarding wizard and weekly_optimize.py manage config.json automatically. You should rarely need to edit it by hand.

config.json

The most important section. Controls how much capital is risked per trade.
"dynamic_position_sizing": {
  "enabled": true,
  "risk_percent": 3.0,
  "min_lot": 0.01,
  "max_lot": 100,
  "max_risk_per_trade_pct": 10.0
}
FieldDescription
risk_percentBase capital at risk per trade, as % of equity
min_lotFloor lot size (never goes below this)
max_risk_per_trade_pctHard cap β€” actual risk never exceeds this % of equity regardless of lot
The equity-aware SL cap formula:
hard_cap_pips = (max_risk_per_trade_pct Γ— equity) / (lot Γ— pip_value)
pip_value = 100 USC per lot per point (VT Markets cent account)
At equity 500 USC: cap = 50 pts. At 2418 USC: cap = 242 pts. Scales automatically as your account grows.

ml_config.json

The feature list is the contract between training and inference. Never reorder, add, or remove features without retraining all 4 models and updating this file.Key groups:
  • Bollinger Bands: bb_upper, bb_lower, bb_width, range_position
  • Trend: price_vs_ema200, trend_strength, macd_signal, ema_crossover
  • Momentum: rsi_14, rsi_divergence, momentum_5, momentum_10
  • Volatility: atr_14, volatility_20, high_low_ratio
  • Volume: volume_ratio, volume_trend
  • Session/news (protected): is_london_session, is_ny_session, is_asian_session, is_news_near, news_minutes_away, news_count_today, is_news_risk_window
  • Account state: drawdown_pct, equity_ratio, win_rate_recent, consecutive_losses
Protected features (never drop based on SHAP):
is_news_near, news_minutes_away, news_count_today, is_news_risk_window
is_london_session, is_ny_session, is_asian_session
"ensemble_paths": {
  "rf": "models/rf_signal.pkl",
  "xgb": "models/xgb_signal.pkl",
  "lgb": "models/lgb_signal.pkl",
  "rf_onnx": "models/rf_signal.onnx",
  "xgb_onnx": "models/xgb_signal.onnx",
  "lgb_onnx": "models/lgb_signal.onnx"
}
Inference priority: calibrated pkl β†’ ONNX β†’ raw pkl. After every retrain, calibrate_models() runs automatically and writes *_calibrated.pkl files.
The risk model uses 7 equity-state features:
"risk_model": {
  "features": [
    "drawdown_pct", "equity_ratio", "win_rate_recent",
    "consecutive_losses", "volatility_20", "atr_14", "hour"
  ]
}
These must stay in sync across ml/risk_trainer.py, ml/risk_predictor.py, and ml_config.json. The model outputs a multiplier in [0.10, 1.25] applied to the base risk percentage.

Broker configuration

Broker-specific parameters live in config/brokers.json. The active broker is set in config.json:
"broker": "vtmarkets_cent"
Each broker entry defines:
{
  "vtmarkets_cent": {
    "account_type": "cent",
    "symbol": "BTCUSD",
    "spread": 16.95,
    "leverage": 500,
    "pip_value": 100,
    "min_lot": 0.01,
    "contract_size": 1
  }
}
pip_value is in USC per lot per point for cent accounts. This drives all equity-aware SL cap calculations.