Skip to main content

Current state — Phase 15 (active)

Signal model

56 features · RF+XGB+LGB · 3-class · M15 · Optuna-tuned
  • Accuracy: RF=43.2%, XGB=43.3%, LGB=42.6%
  • Training cutoff: 2026-03-05 16:00 UTC
  • R2 tag: v20260415

Position model

60 features (56 market + 4 state)
  • ATR-aware labels · exit_threshold=0.80
  • Accuracy: RF=65.1%, XGB=72.2%, LGB=66.8%
  • 135,385 training samples

OOS performance

WindowWRPFMaxDDSharpeScore
37d (Mar–Apr 2026)78.5%2.431.8%32.9921.34
224d (Sep 2025–Apr 2026)57.4%2.2150.2%13.60
Active config: conf=0.60 · prob_diff=0.10 · risk=2.5% · TP=0.8×ATR · SL=1.0×ATR · CB=5

Phase 15 — Production transition (active)

15.0 Broker-agnostic refactor

Complete — 2026-04-18
  • config/brokers.json — central broker registry (VT Markets, IC Markets, Exness, FTMO, FundingPips, generic)
  • config.json → "broker" key selects active broker; all scripts load spread/leverage/swap from registry
  • backtest_config.py — config-faithful backtester; use --max-lot/--cent-account for preset-style comparisons
  • scripts/sweep.py — unified sweep replacing sweep_signal.py + sweep_pos_model.py; --target signal|pos|both
  • scripts/check_broker_limits.py — fixed main guard; added --symbol flag

15.1 Position model validation

Complete — 2026-04-15
  • 38d OOS: PF=4.71 vs baseline 4.27 (+10.3%), MaxDD=4.7%, 1 ML_Exit
  • Sweep of 13 configs via scripts/sweep.py --target pos
  • Thresholds updated: exit=0.80, min_prob_diff=0.25, min_bars_held=4

15.2 Automated retrain pipeline

Complete — 2026-04-17
  • scripts/weekly_optimize.py — 13-phase autonomous pipeline (SHAP → tune → retrain → sweep → evaluate → push → commit → notify)
  • Score improvement gate: 2% minimum to keep new models
VM task pending: Wire cron on trading VM:
0 2 * * 0  cd /path/NOVOSKY && .venv/bin/python scripts/weekly_optimize.py >> logs/weekly.log 2>&1

15.3 Cloud monitoring

Complete — code merged
  • scripts/performance_monitor.py--alert, --lookback, --min-wr, --min-pf, --max-cl flags
  • Thresholds: WR < 55%, PF < 2.0, consecutive losses ≥ 7
VM task pending: 0 */4 * * * cd /path/NOVOSKY && .venv/bin/python scripts/performance_monitor.py --alert --lookback 50

15.4 Telegram bot commands

Complete — 2026-04-15
/help · /pause · /resume · /status · /positions · /close · /closeall · /news · /pnl · /latency Auth-gated by TELEGRAM_CHAT_ID. Pause flag wired into main trade entry loop.

15.5 Broker safety audit

  • Run python scripts/check_broker_limits.py against VT Markets live server
  • Confirm BTCUSD tick size, stops_level, max/min lot
  • Verify swap-free status

15.6 Weekly validation cadence

Complete — 2026-04-17
Covered by weekly_optimize.py — runs full OOS backtest every Sunday, auto-rolls back if Score regresses.

In progress

  • VM cron (15.2/15.3/15.6): Wire weekly_optimize.py + performance_monitor.py on trading VM
  • Phase 15.5: Broker safety audit against live VT Markets — run python scripts/check_broker_limits.py

Phase 16 — Signal quality & risk management

16.1 Walk-forward validation

  • Walk-forward backtest — train 6 months, test next month, roll N times
  • Gate model release on median PF > 2.0, all folds WR > 55%

16.2 Lot sizing improvements

  • Kelly lot sizing backtest (via backtest_config.py lot-cap sweep)
  • Confidence-based position sizing — 60/70/80% tiers scale lot size

16.3 Drawdown guards

  • Enable max_daily_loss — suggested: 15 USD (~3% of $500)
  • Equity curve filter — 10-trade rolling drawdown pause

16.4 Multi-account support

Single trading.py instance managing multiple broker accounts simultaneously via separate mt5api ports.
  • Add --account <id> CLI flag to trading.py to select terminal from config/terminals.json
  • Each broker/account runs its own mt5api instance on a separate port (e.g. 6542, 6543)
  • PM2 multi-instance config — one trading.py process per account
  • Shared model files, per-account state_{account}.json for isolated position tracking
  • Per-account risk config override (different risk% per account/broker)
mt5api already supports multiple accounts via port routing in config/terminals.json. This phase wires up the trading bot side.

Phase 17 — Feature engineering

17.1 On-chain & derivatives features

  • funding_rate — Binance perpetual swap funding rate
  • oi_change — Open interest delta from Binance
  • fear_greed_index — Daily CNN Fear & Greed (0–100)
  • liq_distance_buy/sell — Distance to liquidation cascade zones (Coinglass)

17.2 Market regime features

  • volatility_regime — ATR percentile bucket (Low/Medium/High)
  • corr_spy_20 / corr_dxy_20 — Rolling BTC vs S&P500/DXY correlation
  • w1_ema_bias / w1_rsi_norm — Weekly timeframe features

17.3 Price structure features

  • h4_macd_hist / d1_macd_hist — MACD histogram (not just direction)
  • dom_sin / dom_cos — Day-of-month cyclical encoding
  • ofi — Synthetic order flow imbalance proxy

17.4 Multi-datasource OHLCV pipeline

Aggregate BTCUSD OHLCV from multiple sources to reduce single-broker data bias and improve training robustness.
SourceMethodRole
MT5 broker feedCurrent (live + backfill)Primary
TradingViewWebhook or scraperSecondary
yfinanceyf.download("BTC-USD")Tertiary
OKX / Binance RESTGET /api/v5/market/candlesOptional 4th
  • Design consensus/averaging logic (median OHLCV across sources, flag divergence > 0.5%)
  • ml/data_sources/ module — pluggable source adapters
  • Conflict resolution: use MT5 as primary; fill gaps with secondary sources
  • Impact: more data, cross-broker validation, reduced broker-specific bias
Current focus is BTCUSD only. Multi-source is planning — implement when retraining with fresh data is next scheduled.

Phase 18 — Model architecture

18.1 Ensemble upgrades

  • Stacked meta-learner — replace majority-vote; target +2–5% OOS accuracy
  • Calibrated probabilities via CalibratedClassifierCV(method='isotonic')
  • Ensemble weighting by recency (last 1,000 bars validation accuracy)

18.2 Training improvements

  • Increase Optuna to 150 trials + MedianPruner
  • Online/incremental weekly updates via XGBoost/LGB native continuation
  • Regime-switching model (ADX > 0.25 trending vs ranging)

18.3 Multi-instrument expansion

Each instrument gets its own dedicated model stack — not shared with BTCUSD. Different ATR scaling, different feature weights, different labeling thresholds. Architecture per instrument:
  • ml_config_{SYMBOL}.json — instrument-specific feature list and labeling params
  • models/{SYMBOL}/ — separate ensemble, position, risk model files
  • datasets/training_data_{SYMBOL}.csv — instrument-specific OHLCV dataset
  • Separate backtest_config.py --symbol {SYMBOL} run for OOS validation
Planned instruments:
  • XAUUSD (gold CFD) — different ATR (530vs5–30 vs 50–200 BTC), different session sensitivity
  • EURUSD (forex) — pip-based P&L, tighter spreads, different news calendar
  • Cross-asset features (BTC–Gold correlation, BTC–ETH spread) — Phase 17 first
Do not share model files across instruments. Scaler and feature distributions differ too much. Always train per-symbol.

Phase 19 — Infrastructure & operations

19.1 Observability

  • Live Streamlit dashboard — equity curve, open positions, signal feed
  • Grafana + InfluxDB time-series metrics pipeline
  • /health HTTP endpoint from trading process

19.2 Reliability

  • API failover — alert + SAFE_PAUSE after 3 consecutive failures
  • Graceful shutdown — finish current bar, cancel pending orders, write shutdown state
  • Config hot-reload — poll config.json mtime every 60s

Phase 20 — MQL5 EA (standalone native client)

20.1–20.2 Core EA framework + scaler

  • mql5/src/NovoskyEA.mq5 skeleton with OnInit/OnDeinit/OnTick
  • Load all 6 ONNX models via OnnxCreate() with #resource paths
  • ScalerConstants.mqh auto-generated from scripts/extract_scaler_constants.py

20.3 Feature computation in MQL5

  • Replicate all 56 features in native MQL5
  • Multi-timeframe resampling (H4, D1 from M15) without API calls
  • Parity test: MAE < 0.001 vs Python on same 100 bars

20.4–20.5 Signal + position inference

  • Majority-vote inference over 3 signal ONNX models
  • ATR-based SL/TP + trade_stops_level enforcement
  • 59-feature position inference — EXIT on threshold

20.6 Distribution

  • Package EA + resources ZIP into single EX5 under 20 MB
  • Submit Free tier (signal only) + Premium tier (signal + position) to MQL5 Market

Full quarterly roadmap → Roadmap.

Completed phases (1–12)

Phase 1 — Fix the model

  • SELL recall improved 3% → 30% by adding 5 directional features: ema_stack, candle_direction, volume_delta, rsi_slope, consecutive_direction
  • TP=0.3% / SL=0.25% tuning: WR 60.6%→77.3%, PF 1.48→2.85, MaxDD 12%→6.3%
  • Training data extended 365 → 730 days; lookahead_candles 12 → 24
  • LightGBM feature-name warning fixed (pass numpy array directly)

Phase 2 — Multi-timeframe features

  • H4/D1 features resampled from M15: h4_ema_bias, h4_rsi_norm (#5 SHAP), h4_macd_dir, d1_trend, price_vs_d1_open (#7 SHAP)
  • Session flags: is_london_session, is_ny_session, is_asian_session, session_hour_sin/cos
  • Volatility/momentum: atr_percentile (top feature), volume_surge, bb_squeeze, price_acceleration
  • S/R proximity: dist_to_round_number (#1 SHAP overall), near_daily_high_low, adx_14, market_quality, momentum_decay, adverse_candle_ratio
  • ATR-aware labeling groundwork: create_labels_atr_aware() added (activated in Phase 10)

Phase 3 — Hyperparameter tuning + SHAP

  • Optuna 50-trial tuning: WF 44.9%→45.7%, PF 2.82→2.96, MaxDD 7.6%→3.8%, Sharpe 7.23→8.63
  • SHAP analysis: ml/shap_analysis.py with TreeExplainer; beeswarm plots; models/shap_summary.json
  • Top SHAP features: h4_rsi_norm > atr_14 > hourly_return > price_vs_ema200 > session_hour_sin
  • Feature pruning tested and rejected — removing low-SHAP features hurt performance (WR 55.9%→50%)
  • Sequence model deferred (CPU-only hardware too slow)

Phase 4 — Risk management (superseded)

Items superseded by ML-driven config sweeps in Phases 9/13/14.
  • EMA trend filter, partial profit taking, trailing stop — all superseded by ML active management
  • max_weekly_drawdown_pct added to config.json (2026-04-11)

Phase 5 — Backtesting

  • backtest_config.py built: config-faithful OOS backtester with ONNX inference; WR, PF, Sharpe, MaxDD, Return
  • v8 results (1yr OOS, 48 features): Setup A WR=76.4% PF=3.20 MaxDD=2.6% | Setup D Return=+747%
  • Walk-forward backtest deferred to Phase 16

Phase 6 — Automation & monitoring

  • scripts/performance_monitor.py — WR/PF/consecutive losses; Telegram alert
  • Signal logging to models/ml_performance.csv
  • scripts/dashboard.py CLI trade summary

Phase 7 — Live trading integration

  • Migrated trading.py from MetaTrader5 Python package to NOVOSKY HTTP API
  • --dry flag added for safe testing
  • Paper trade validated via OOS backtest: WR=82.7%, PF=4.27, MaxDD=5.2%

Phase 8 — ML active trade management (2026-04-10)

  • Dedicated position model: RF+XGB+LGB on 60 features (56 market + 4 position-state)
  • Labels: HOLD / EXIT / ADD — ml/position_labeling.py + ml/position_trainer.py
  • PositionPredictor.get_position_action() with 2/3 majority vote
  • Kelly-adjusted lot sizing, ML-based SL/TP scaling, partial close, trailing stop
  • Results: Signal WF=43.66%, Position ensemble=73.50% | Setup E: WR=78.8% PF=4.52 MaxDD=1.6%

Phase 9 — Growth config sweep (2026-04-10)

  • Goal: maximize monthly return for $10k account, IC Markets RAW
  • Best: conf=0.55, risk=20%, max_lot=10, all Phase 8 active management disabled
  • Result: WR=57.4%, PF=1.75, MaxDD=15.0%, Sharpe=4.68, Return=+8449%, ~340 trades/yr

Phase 10 — Deep optimization (2026-04-11)

Four critical bugs fixed and retrained:
  1. Label-execution mismatch — activated atr_aware labeling in ml_config.json
  2. Class imbalance — replaced downsample with compute_sample_weight('balanced')
  3. Spread underestimationbacktest_config.py spread fallback 0.300.30 → 16.95
  4. ADX regime filter — new adx_regime_filter block in config.json
Retrain result: WR 48.8%→78.6%, PF 1.15→2.91, MaxDD 59.8%→22.1%, Sharpe 2.71→14.11

Phase 11 — M15 scalping + local timezone support (2026-04-11)

  • H1 → M15 timeframe; 112 trades/yr → 477 trades/yr (1.31/day)
  • ATR-aware labels: SL=0.8×ATR, TP=1.5×ATR, lookahead=48 bars
  • sl_atr_multiplier 1.0→0.8; min_atr 50→15; ADX filter disabled
  • Local timezone support via config.json; Telegram redesign
  • Backtest: WR=63.7%, PF=3.05, MaxDD=19.6%, Sharpe=7.29, Return=+1,284,866%

Phase 12 — Production hardening (2026-04-12)

15 critical issues resolved:
  • API retry with exponential backoff (3× on network errors)
  • Atomic state.json writes via .tmpos.replace()
  • tracked_positions persisted to state.json — survives PM2 restarts
  • risk_percent 6→2; max_consecutive_losses 10→5; max_weekly_drawdown_pct 0→20
  • Full retrain: fresh 2yr M15 data, Optuna 50-trial local tuning, OOS backtest