Commit Graph
29 Commits
Author SHA1 Message Date
Luke Mosoti 25fd6a6eea feat: Update optimization process with Combinatorial Purged CV; enhance cyclical time features and adjust model parameters 2026-05-19 21:56:25 +03:00
Luke Mosoti d947e79097 Refactor optimizer parameters and add new model configuration
- Updated search space for `n_states` in models M15 and M5 from categorical to integer range (3 to 4).
- Lowered `reg_alpha` and `reg_lambda` ranges to allow HMM OHE signal through for models M15 and M5.
- Adjusted the `make_objective` function to reflect changes in parameter suggestions for M5 and M15.
- Introduced new model configuration file for stage1 M15 with optimized parameters and score.
- Added binary changes to the study_headway_cent database.
2026-05-19 20:32:21 +03:00
Luke Mosoti 91194835cc Update README: Remove Changelog section, enhance feature descriptions, and clarify external asset roles 2026-05-14 11:56:17 +03:00
Luke Mosoti 9f8d61bdc0 Fix notebook merge conflicts, update ensemble API, and update README
- Resolve 5 committed git merge conflict markers in GoldRegimeX_Explorer.ipynb
  that rendered it invalid JSON and unexecutable in Jupyter
- Conflict resolution: keep wfo_mode_w dropdown, reg_lambda5_w / min_child_weight5_w
  sliders, Run WFO Score Comparison button, and Section 6 CV Path Inspector from
  copilot branch; keep ensemble API imports (load_xgb_ensemble, get_predictions_ensemble)
  from HEAD
- Fix notebook Sections 1 and 5 to use load_xgb_ensemble / train_xgb_ensemble /
  get_predictions_ensemble instead of old single-model API; ensures equity curves
  and WFO scores match production vol-bucketed ensemble
- Update README changelog with merge conflict resolution and ensemble API fix entry
2026-05-14 10:49:45 +03:00
7132851128 Rewrite README.md to document all WFO bug fixes, scoring formula changes, Optuna improvements, and new notebook sections
Agent-Logs-Url: https://github.com/lucasmos/GoldRegime_X/sessions/975bbd90-d267-4b2a-af8a-1d4eb67cd2b7

Co-authored-by: lucasmos <160877590+lucasmos@users.noreply.github.com>
2026-05-14 07:13:18 +00:00
Luke Mosoti 77caf6db0a Refactor signal evaluation logic: remove SignalEvaluator and introduce SignalEngine
- Deleted `signal_evaluator.py`, which contained the previous Z-Score and RCEV evaluation logic.
- Added `signal_engine.py`, implementing a new stateful signal engine for regime confirmation and trade management.
- The new engine evaluates entry and exit conditions based on regime stability, XGBoost confidence, and Bollinger Band positions.
- Introduced constants for minimum confirmation bars, entry probabilities, maximum hold bars, and profit erosion thresholds.
2026-05-09 08:52:33 +03:00
Luke Mosoti a6f72863ef feat: Implement Regime-Conditional Expected Value (RCEV) scoring system
- Introduced RCEVScorer class for calculating expected dollar profit based on historical trade outcomes and market conditions.
- Replaced Z-Score signal gating with RCEV scoring in SignalEvaluator for live evaluations.
- Added new configuration for RCEV thresholds and tiered floors based on timeframes.
- Enhanced MT5 trader logic to utilize RCEV scoring for trade decision-making, including regime-aware take-profit and stop-loss calculations.
- Updated ATR trailing stop logic to incorporate new RCEV parameters and configurations.
- Maintained backward compatibility with existing Z-Score logic for scenarios without RCEV calibration.
2026-04-29 09:17:28 +03:00
Luke Mosoti 8754b7f9d6 Remove LSTM model files and metadata for H1 and M15 headway cent models
- Deleted ensemble metadata, feature scalers, and model metadata for H1 headway cent models.
- Removed LSTM regime classifier files for H1 headway cent models.
- Deleted corresponding files for model_0, model_1, and model_2 in both H1 and M15 headway cent directories.
- Cleaned up unnecessary files to streamline the model directory structure.
2026-04-27 22:28:26 +03:00
Luke Mosoti 94f6e6ae9b docs: comprehensive README rewrite covering all V5 features
- Full workflow from raw data to live trading (Phase 0–7)
- LSTM ensemble, temperature calibration, fine-tuning, staleness/auto-retrain
- Sensitivity analysis and tiered Z-Score trading modes
- Updated command reference (all 16 modes + 22 CLI options)
- Signal logic with exact TF Z-Score cutoffs
- Guardian LSTM auto-retrain documentation
- Model files layout and troubleshooting guide
2026-04-25 14:23:16 +03:00
Luke Mosoti 42eef47cb2 feat: implement MR execution — TF-specific Z-Score cutoffs, MR attribution, tighter SL
signal_evaluator.py:
- Raise Z_CUTOFF_CHOP_MR default from {2:2.2, 3:2.8} → {2:3.2, 3:3.8}
- Add _TF_CUTOFF_OVERRIDES: H1=±2.5/MR{3.0,3.5}, M15=±2.3/MR{3.0,3.5},
  M5=±2.8/MR{3.5,4.0}; add tf param to SignalEvaluator.__init__

backtester.py:
- Add tf param to compute_signals_zscore; passes TF-specific cutoffs to evaluator
- Add _mr_attribution() helper: classifies trades as trend vs MR by HMM state
- vectorized_backtest now outputs mr_trades, mr_win_rate, mr_pnl (+ oos_ prefixed)

mt5_trader.py:
- SignalEvaluator(regime_stats, tf=tf) — live trading now uses TF-specific cutoffs
- MR SL reduced to 0.70× base ATR SL for mean_reversion signal_type
- Order comments now tagged: GRX_{TF}_TREND_{DIR} / GRX_{TF}_MR_{DIR}

optimizer.py:
- Log MR trade stats (MR Trades | WR | P&L) per trial when oos_mr_trades > 0

README.md:
- Update Z-Score cutoff table and flow diagram to TF-specific values
- Document MR SL reduction (0.70×) in Staged TPs table
- Update comment format table with TREND/MR tag
- Add mr_trades, mr_win_rate, mr_pnl to All Reported Metrics
- Update architecture table entries for signal_evaluator and backtester
2026-04-22 23:04:14 +03:00
Luke Mosoti b1d98abb7c docs: rewrite README for Z-Score signal architecture (V5)
- Replace fixed prob_threshold/short_threshold docs with Z-Score calibration overview
- Document new src/signal_evaluator.py module
- Update signal logic section: per-regime Z-Score cutoffs table, 3 MR live safety gates (chop stability, transition prob, BB confluence), universal adaptive confirmation
- Update optimizer section: threshold params removed from search space; all study DBs must be deleted and re-optimized
- Update report section: 6 charts (adds MT5 balance/equity chart)
- Update architecture table with signal_evaluator.py and updated visualizer/backtester descriptions
- Add stale-studies warning box in optimizer and anti-overfitting sections
- Remove --prob_threshold / --short_threshold from command reference
- Update How It Works diagram with k-means HMM init and Z-Score routing
2026-04-22 15:34:10 +03:00
Luke Mosoti 2a02907536 docs: comprehensive README update — MR signals, multi-TF magic, DailyEquityGate, HMM 3-feature obs
- How It Works: add HMM 3-feature obs (kalman_return/volatility/rsi_slope) + StandardScaler note
- Signal Logic: add Mean Reversion (Chop state) section with thresholds, MR WARNING, Logic Audit
- Signal Logic: update H1 BUY threshold range to 0.65–0.80 (raised from 0.55–0.72)
- Signal Logic: add Global Guard row to signal conditions table
- New section: Multi-TF Live Trading — TF_MAGIC_MAP, Global Guard, TF-tagged comments, midnight audit
- Risk Management: replace per-TF max-daily-trades table with DailyEquityGate two-sided gate section
- Timeframe Configurations: HMM persistence gate 0.72→0.65; add DailyEquityGate profit lock rows
- Optimizer Anti-Overfitting: persistence gate note updated to 0.65
- Step 6 report: update chart list with attribution markers, 2D regime scatter, Profit Attribution table
- MQL5 EA: update magic number note for per-TF magic map
- Troubleshooting: add MR warning, global guard, and conflict warning entries
- Architecture table: note 3-feature obs normalisation in engine_hmm row
- Update study_headway_cent.db
2026-04-18 12:59:03 +03:00
Luke Mosoti 42d4ebefd7 docs: add recommended trial counts per TF (M5=1000, M15=600, H1=400) 2026-04-16 20:55:09 +03:00
Luke Mosoti 03755ca26c docs: comprehensive README update covering all new features and metrics 2026-04-16 18:22:08 +03:00
Luke Mosoti b6b058927e feat: per-TF USDCHF consolidation + H1 optimizer recovery + MT5 data guide
- data_consolidator: add consolidate_usdchf_m15/m5 producing USDCHF_master_M15.csv
  and USDCHF_master_M5.csv; H1 legacy fallback now excludes M5/M15 filenames
- processor: _USDCHF_PATH_BY_TF lookup so each TF loads its matching-frequency
  USDCHF master (H1→master.csv, M15→master_M15.csv, M5→master_M5.csv)
- main: cmd_consolidate runs all three TF consolidations in one pass with per-TF summary
- optimizer: H1 n_states reverted [3,4], obs_cov floor raised 0.1→0.5,
  MIN_OOS_TRADES_BY_TF["H1"] lowered 200→75
- risk_manager: H1 headway_cent small-account daily cap raised 1→2 trades
- README: per-TF USDCHF filename/master table; dedicated "Getting deep history from MT5"
  section (any symbol, any TF) with MetaQuotes-Demo Pro Tip
2026-04-12 21:40:54 +03:00
Luke Mosoti 29d42b44fd feat: add Walk-Forward Analysis and model staleness checks to enhance trading strategy evaluation 2026-04-12 17:57:50 +03:00
Luke Mosoti 236a85270b feat: broker-specific report directories + add --mode report to all TF workflows
- visualizer.py: _tf_dir now uses reports/<TF>_<broker>/ so M5_headway_cent
  and M5_standard charts save to separate folders and never overwrite each other
- All 5 plot functions + generate_full_report accept broker= param and pass it through
- main.py cmd_report: passes broker= to generate_full_report; print updated to
  show reports/<TF>_<broker>/ path
- README.md: --mode report added to all four per-TF workflows (H1, M15, M5 cent,
  M5 standard); Step 6 updated with correct broker-specific folder tree; command
  reference table updated with broker-specific path description
2026-04-11 20:30:49 +03:00
Luke MosotiandClaude Sonnet 4.6 d21069d958 docs: add Chop_Low/Chop_High state labels for n_states=4 (M5)
- State Labels section rewritten: shows Chop (n_states=3), Chop_Low=2
  and Chop_High=3 (n_states=4) with mean-return rank explanation
- Added explanation of why M5 uses two Chop sub-states and what
  distinguishes them (log-return rank, not volatility)
- Signal logic table updated: "Chop state (2 or 3)" blocked
- Regime-aligned filter note updated to reference both state 2 and 3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 21:47:09 +03:00
Luke MosotiandClaude Sonnet 4.6 57cc1d30f6 docs: update README for hybrid scalp protection, pos_per_trade, and TP3
- Hybrid Scalp Protection section: fixed scalp target ($4/position),
  trailing guard ($2 activation, 50% drawdown), both per-position
- Staged TPs: M5 growth accounts (>$50) now have TP3 at 3.0x SL;
  small accounts (<=$50) use TP1+TP2 only (clamped by min(pos_per_trade, len(tps)))
- Risk Management table: pos_per_trade=2 for <=$50, pos_per_trade=3 for >$50;
  removed outdated standard account guard row
- Timeframe Configurations: added pos_per_trade rows, TP3, trailing guard params
- Command Reference: added --profit_target option
- Standard account section: removed $500 minimum recommendation and old guard note
- Troubleshooting: updated EA conflict entry to mention startup CONFLICT warning
- Step 9: updated EA conflict note with accurate description of what goes wrong

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 21:40:29 +03:00
Luke MosotiandClaude Sonnet 4.6 6f296adb3b docs: full README.md rewrite — cent/standard accounts, new modes, broker-specific models
- Add Cent vs Standard account section with P&L conversion tables
  (explains that +$2.40 cent = $0.024 real USD, standard is 1:1)
- Remove all paper trading / --account demo|live references;
  replace with --mode demo (real orders, no prompt) and --mode live (real orders, YES prompt)
- Update model file references to broker+TF naming convention
  (hmm_model_H1_headway_cent.pkl etc.)
- Update study DB references to per-broker files (study_headway_cent.db / study_standard.db)
- Add M5 standard account workflow with prob_threshold 0.55-0.60 rationale
- Signal logic table updated: regime-aligned filter (Bull=BUY only, Bear=SELL only, Chop=blocked)
- Probability threshold table per TF per broker with search ranges
- Spread viability guard: cent M5-only 1.5x vs standard all-TFs 3.0x
- Standard account guard documented in risk management table
- Data freshness section explaining IS/OOS split dates and sync_validate scope
- Degenerate HMM training abort guard documented
- Troubleshooting table updated; removed dry_run/--account demo row
- State labels table updated with signal eligibility notes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 11:26:31 +03:00
Luke MosotiandClaude Opus 4.6 0b28cf196d feat: raise M15 daily trade cap to 4 to match M5
M15 generates ~96 bars/day vs M5's 288 — both now get a 4-trade/day
cap for small accounts so the optimizer can clear MIN_OOS_TRADES=200
thresholds during the coming re-optimization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 18:00:23 +03:00
Luke MosotiandClaude Sonnet 4.6 b5106860f7 feat: M5 scalping refinements — profit guard, tighter TPs, threshold tuning
Align H1 TP config with M15 — reduce over-ambitious targets:
- H1 trending: [1.5, 3.0] -> [1.0, 2.0]  (TP2=3.0 rarely filled; 2.0 is
  achievable in a strong H1 trend day; mirrors M15 ratio)
- M15/H1: profit guard (70% to TP1 -> SL to entry+2×spread), break-even
  (TP1 hit -> runner SL to entry), chop-exit (regime shift closes runner)
  were already all-TF — confirmed in code comments and loop logic
- README: update staged TP table with per-TF values and profit protection
  chain; fix Timeframe Configurations table with correct TP1/TP2 values
  and Min OOS trades updated to reflect M15=200/H1=200

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 17:49:37 +03:00
Luke MosotiandClaude Sonnet 4.6 d1bf7af883 feat: narrow H1/M15 prob threshold search space to prevent over-conservative models
- prob_threshold: 0.52-0.65 -> 0.50-0.58 (ceiling cut stops optimizer settling
  at 0.64 where only 40 trades fire per OOS window)
- short_threshold: 0.35-0.48 -> 0.42-0.50 (raises floor for symmetric buy/sell
  sensitivity; was asymmetrically biased against shorts)
- README: update probability threshold table for M15 and H1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 23:14:59 +03:00
Luke MosotiandClaude Sonnet 4.6 3ff132914b fix: M5 4-trade/day cap, TF-aware model loading, USDCHF README update
- risk_manager: store tf in AdaptiveRiskManager.__init__; get_trade_limits
  and can_trade use self.tf by default — M5 small accounts correctly get
  4 trades/day without threading tf= through every call site
- mt5_trader: pass tf=tf to both AdaptiveRiskManager instantiations so
  the live loop displays and enforces trades=0/4 for M5 (was 0/2)
- README: DXY -> USDCHF throughout; TF-specific model file names; M5/M15/H1
  workflow sections; consolidate mode in command reference; correct
  short_threshold table; M5 n_states restriction note; updated trade limit
  table showing M5 4/day cap; period 6m recommendation for H1/M15 validate
- models/m5_meta.json: updated with latest optimization result (score 4.49)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 22:44:45 +03:00
Luke MosotiandClaude Opus 4.6 9af5cd38a5 docs+fix: volatility ensemble docs, DXY forward-fill, validator ensemble API
- README: add dedicated Volatility Ensemble section documenting three-model
  bucketing (low/med/high ATR), feature table, threshold explanation, and
  ONNX file list; update pipeline diagram, train/export descriptions, and
  prob_threshold range (0.505-0.60)
- optimizer.py: lower prob_threshold search space lower bound 0.52 → 0.505
  so Optuna can find thresholds matching the model's real output range
- processor.py: add map_dxy_to_bars() helper that forward-fills DXY beyond
  file coverage (handles sync data newer than last DXY export); fix
  load_dxy_data() date format to match YYYY-MM-DD saved format
- validator.py: use load_xgb_ensemble + get_predictions_ensemble; import
  and apply map_dxy_to_bars in _apply_features() so DXY is included in
  validation inference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 22:46:01 +03:00
Luke MosotiandClaude Opus 4.6 97474652b6 refactor: consolidate DXY to single shared raw file for all timeframes
DXY is a daily index exposed by MT5 only at the day level — there is no
per-timeframe variant.  Remove the three separate dxy_raw_path entries
from TF_CONFIG and replace them with a single module-level DXY_RAW_PATH
constant (data/raw/DXY_data.csv) that all timeframes share.

process_pipeline() now references DXY_RAW_PATH directly; the pipeline
degrades gracefully (4-feature model) if the file is absent.

README Data Setup section updated with DXY export instructions and the
single expected filename.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 01:24:02 +03:00
Luke MosotiandGitHub dfab542b6b Update README to include M15 and M5 timeframes 2026-03-30 23:57:49 +03:00
Luke MosotiandClaude Sonnet 4.6 50409ac18e docs: comprehensive README with full setup, workflow, and architecture guide
Covers installation, data setup, Telegram config, full step-by-step workflow
for H1/M15/M5 timeframes, signal logic, risk management, MQL5 EA, and
troubleshooting. Replaces the auto-generated GitHub placeholder.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 23:55:05 +03:00
Luke MosotiandGitHub 5b639d98b5 Initial commit 2026-03-30 23:44:27 +03:00