203 Commits
Author SHA1 Message Date
Luke Mosoti a89156b402 feat: add strategy backtesting module for live model evaluation
- Introduced `strategy_backtest.py` as a single source of truth for scoring and backtesting.
- Implemented functions to load live model bundles, build feature frames, and execute backtests.
- Ensured consistency between optimized models and their validation/trading counterparts.
- Added functionality for generating trading signals and retrieving the latest trading decision.
2026-07-31 21:52:30 +03:00
Luke Mosoti bbc36d2395 Add lot escalation what-if analysis CSV report
This commit introduces a new CSV file containing the results of a lot escalation what-if analysis. The report includes various regimes, timeframes, trade counts, net profits, final balances, final equities, returns, maximum drawdowns, and profit factors for different escalation scenarios.
2026-07-30 14:56:49 +03:00
Luke Mosoti 75736fe516 Refactor code structure for improved readability and maintainability 2026-07-29 00:24:42 +03:00
Luke Mosoti 82b1e9f559 Refactor code structure for improved readability and maintainability 2026-07-20 20:28:36 +03:00
Luke Mosoti 06bfc0debe Refactor code structure for improved readability and maintainability 2026-07-16 16:24:41 +03:00
Luke Mosoti 299b5965fa Update pipeline reports and diagnostics for M15 and M5 timeframes
- Adjusted session consistency test results to reflect empty DataFrame.
- Updated candidate counts and hashes in pipeline manifest explorer.
- Modified Explorer Diagnostics CSV files to reflect new execution counts and removed unnecessary columns.
- Revised signal loss reports for M15 and M5 to remove stage information while retaining lost counts.
- Enhanced explorer consistency report with updated generated and loaded counts, along with TBM, HMM, XGB pass rates, and executed trades.
2026-07-16 10:04:06 +03:00
Luke Mosoti 8a6b4fdf07 Add pipeline certification and profiling modules with self-validation
- Introduced `pipeline_certification.py` for Phase 13 checks on the observability layer, including stage order, monotonicity, unique IDs, and stale reports.
- Implemented `pipeline_profiler.py` for event-based profiling, ensuring integrity across pipeline stages and providing methods for recording events and generating reports.
- Created `prediction.py` to standardize prediction results and ensure compatibility across different components.
- Added a smoke test script to validate module imports and function signatures before running notebooks.
2026-07-16 08:43:56 +03:00
Luke Mosoti 57c5eba042 Add forensic spec emitters for pipeline observability reports
- Implemented survival analysis report generation with CSV output.
- Added probability report generation with summary statistics.
- Introduced feature drift report with metrics for monitoring shifts.
- Created HMM regime report for per-timeframe analysis.
- Developed self-verification table to ensure required artifacts are present and contain data.
- Added new CSV files: probability_report_M5.csv and survival_analysis.csv.
2026-07-15 11:11:01 +03:00
Luke Mosoti e6610e0b97 Update pipeline health reports and rejected candidates data
- Enhanced pipeline_health.txt to include metrics for M15 and M5, highlighting generated, executed, and survival rates, along with bottleneck information.
- Added detailed rejection records for M15 and M5 in top100_rejected_M15.csv and top100_rejected_M5.csv, respectively, indicating the filtering stage and reasons for rejection.
2026-07-14 12:29:47 +03:00
Luke Mosoti 62c1119fa2 chore: clean up code structure and remove unused code blocks 2026-07-14 11:41:19 +03:00
Luke Mosoti d839902e6c Fix execution counts and update outputs in GoldRegimeX_Explorer_fixed.ipynb
- Set execution counts for initial cells to 1, 2, 3, 4, and 5 respectively.
- Replace error outputs with informative stdout messages for better clarity.
- Add error handling for missing bridge file with a clear message to run Strategy_Tester first.
2026-07-14 07:45:14 +03:00
Luke Mosoti 0f449a0eda Remove obsolete patch scripts for Explorer notebook cells and add new bfg.jar file. 2026-07-14 07:40:12 +03:00
Luke Mosoti aaa843681c Untrack >100MB report artifacts 2026-07-13 22:36:26 +03:00
Luke Mosoti e4b025f87c Add reports as plain files 2026-07-13 21:45:38 +03:00
Luke Mosoti d53e954f96 Add .gitattributes to manage CSV and JSON files with LFS 2026-07-13 15:59:42 +03:00
Luke Mosoti 0cf2a7a382 fix: correct grammar in documentation for observability module 2026-07-13 15:44:03 +03:00
Luke Mosoti 067d319984 Add new CSV files for smoke tests including probability summary, session audit, stage survival, and top rejected candidates 2026-07-13 14:30:26 +03:00
Luke Mosoti 2f13c915ac Add smoke test for pipeline observability
This commit introduces a new smoke test script that exercises every phase of the pipeline observability process. The test generates synthetic data for two timeframes (M15 and M5), simulating various stages of the pipeline and verifying that all artifacts are produced and non-empty. The script includes assertions to ensure the integrity of the generated outputs and checks for expected conditions in the decision log, survival matrix, and audit JSON.
2026-07-13 11:11:18 +03:00
Luke Mosoti 900186dcb7 Refactor GoldRegime_X workspace configuration and add patch scripts for notebook verification
- Updated GoldRegime_X.code-workspace to remove deprecated server configuration.
- Added package.json and package-lock.json to manage dependencies, specifically @notionhq/client.
- Introduced patch_explorer_cell46.py to resolve ModuleNotFoundError in the PIPELINE VERIFICATION import cell of GoldRegimeX_Explorer.ipynb.
- Created patch_explorer_cell48.py to fix NameError for TIMEFRAMES in the Dataset Integrity verification cell, ensuring it can derive TIMEFRAMES from the pipeline if not already defined.
2026-07-10 09:13:17 +03:00
Luke Mosoti 370b877190 ci: mirror pushes to lukes-organization/GoldRegimeX2 2026-07-10 08:48:08 +03:00
Luke Mosoti d903ae82cf ci: mirror pushes to lukes-organization/GoldRegimeX2 2026-07-10 08:37:11 +03:00
Luke Mosoti 5110d693c7 Add MCP server configuration to workspace settings and create mcp.json file 2026-07-07 16:48:49 +03:00
Luke Mosoti c75e5c7bad Add central pipeline verification module and session filter implementation
- Introduced `pipeline_verification.py` containing multiple verifier classes for dataset integrity, feature leakage, evaluation integrity, prediction alignment, and more.
- Added `SessionFilter` class in `session_filter.py` for unified session/time-of-day filtering.
- Implemented `VerificationResult` data class for structured verification results.
- Created utility functions for hashing and manifest building.
- Established a test suite for the session filter to ensure correct functionality.
- Updated `__init__.py` to include the new shared module.
2026-07-07 16:04:10 +03:00
Luke Mosoti 6a2bce1d65 Remove lifecycle parity, unit, and three-state contract tests
- Deleted `test_lifecycle_parity.py`, which contained tests for lifecycle event timelines in live and backtest scenarios.
- Deleted `test_lifecycle_units.py`, which included unit tests for lifecycle configurations and floating PnL calculations.
- Deleted `test_three_state_contract.py`, which verified the enforcement of three semantic states across various components.
2026-07-02 13:42:05 +03:00
Luke Mosoti 71a6c90426 Update strategy tester notebook with new results and adjusted max drawdown limit
- Updated parallel processing output times to reflect new execution durations.
- Modified strategy results table with new entries and adjusted values for fixed_tp and fixed_tp_plus_mr strategies.
- Increased maximum drawdown percentage from 30.0 to 35.0.
- Enhanced filtering logic to ensure proper retrieval of results from all_results or valid_results.
2026-07-02 12:00:40 +03:00
Luke Mosoti 3c985fdb4c fix: Loosen M15 ADX/RSI grids and sync regime threshold to 15.0
- Strategy_Tester: ADX_GRID [15.0, 18.0, 20.0], PULLBACK_RSI_GRID [35.0, 40.0, 45.0, 50.0]
- Strategy_Tester: regime is_trend threshold 20.0 -> 15.0
- Explorer: regime is_trend threshold 20.0 -> 15.0
- .gitignore: add nul and .kilo/ entries
- Deleted nul file from repo
2026-06-29 21:45:19 +03:00
Luke Mosoti 2dff0baa02 Add scripts for generating strategy reports and smoke testing Explorer integration
- Implemented `generate_bridge_csv.py` to generate reports for strategy winners from the Strategy Tester notebook.
- Added `smoke_test_explorer.py` to perform smoke tests on the Explorer notebook integration, validating core logic and data processing.
2026-06-19 11:07:05 +03:00
Luke Mosoti 392e408c11 feat: Enhance signal engine and reporting capabilities
- Updated signal engine logic to improve trade decision-making with new probability thresholds and dynamic gates.
- Introduced new `cpcv_reporting.py` module for generating comprehensive CPCV reports, including optimization summaries and performance metrics.
- Added `optuna_param_guard.py` to enforce parameter validation for Optuna optimization, ensuring only approved parameters are used.
- Created `regime_diagnostics.py` for summarizing regime statistics and trade distributions, facilitating better analysis of trading strategies.
2026-05-31 13:51:13 +03:00
Luke Mosoti c1dbf315c8 Add comprehensive lifecycle and regime tests
- Introduced `test_lifecycle_parity.py` to verify event timelines between live and backtest evaluations, ensuring consistent activation, partial close, scalp exit, and regime shift behaviors across different timeframes.
- Added `test_lifecycle_units.py` for unit testing of lifecycle configurations, including cent normalization, activation thresholds, and the absence of R-multiple fields.
- Created `test_three_state_contract.py` to enforce and validate the three-state regime (TREND, MEAN_REVERSION, VOLATILITY_SHOCK) across various components, ensuring that any attempt to use more than three states raises appropriate errors.
2026-05-31 00:07:44 +03:00
Luke Mosoti 6850d21643 Refactor validation logic to incorporate regime models and enhance strategy validation checks
- Integrated regime model predictions into the validation process, allowing for fallback to ensemble models.
- Updated validation criteria to include checks for maximum drawdown, minimum trades, and MR leaks.
- Enhanced test suite to cover new validation scenarios and ensure robustness of strategy evaluation.
- Adjusted signal pipeline audit tests to reflect changes in regime handling and validation logic.
2026-05-30 18:18:17 +03:00
Luke Mosoti d4b533a9eb feat: Add specialized features for M15/M5 trading strategy
- Implemented `add_specialized_features` to compute ATR moving averages, expansion ratios, realized volatility ratios, and session proximity features.
- Integrated the new feature set into the processing pipeline.
- Updated `run_sensitivity` to utilize new Z-score thresholds from `SignalEngine`.
- Refactored `SignalEngine` to include a unified `SignalDecision` class for consistent entry/exit logic.
- Enhanced `evaluate_bar` to incorporate dynamic probability thresholds and M15 entry gates.
- Added comprehensive tests for signal generation, decision parity, and dynamic thresholds.
2026-05-30 13:01:16 +03:00
Luke Mosoti f2a9f994a9 Update study_headway_cent database file with new data 2026-05-20 00:47:02 +03:00
Luke Mosoti 590911e2fe Refactor feature preparation and live feature computation for M5/M15 regimes
- Updated `get_feature_cols` to handle one-hot encoding for HMM states in M5/M15.
- Modified `prepare_features` to include a rolling median for HMM states and drop the original integer state.
- Enhanced `compute_live_features` to generate one-hot encoded features for M5/M15 and retain the integer state for H1.
- Implemented runtime checks to ensure live feature keys match training columns, raising errors for mismatches.
- Adjusted scoring logic in `optimizer.py` to apply log-loss for M5/M15 and backtest for H1, improving robustness against over-regularization.
2026-05-20 00:12:30 +03:00
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 34a1a593f1 feat: Enhance data synchronization and processing for XAUUSD
- Implemented auto-sync for raw CSV data from MT5 in cmd_optimize, ensuring missing bars are appended if the terminal is running.
- Added ensure_data_updated function in mt5_sync.py to check and fetch missing bars for specified timeframes, logging warnings if MT5 is unavailable.
- Introduced median filtering in engine_hmm.py to smooth HMM state predictions, reducing noise from regime flips.
- Updated predict_states to apply median filtering after state remapping for consistency.
- Added time-of-day gating in processor.py to filter out Asian-session bars, retaining only London/NY high-liquidity hours for analysis.
2026-05-19 15:27:19 +03:00
Luke Mosoti 5d3bdf5319 Refactor trading strategy with dynamic ATR bands and synth VIX z-score integration
- Removed obsolete model configuration file `stage1_m15_headway_cent.json`.
- Updated database file `study_headway_cent.db` to reflect changes in model parameters.
- Enhanced backtester to utilize dynamic ATR bands and synth VIX z-score for entry signals.
- Modified engine to include new features: `atr_band_position` and adjusted feature importance.
- Implemented dynamic ATR band calculations in the processor module.
- Adjusted signal engine logic to incorporate new thresholds for trend and mean-reversion entries based on ATR bands and z-scores.
- Updated optimizer parameters for improved model performance.
2026-05-18 22:08:59 +03:00
Luke Mosoti 0c364b7b3c feat: Update trading strategy parameters and thresholds; add new model configuration for M15 broker 2026-05-18 19:34:15 +03:00
Luke Mosoti 16c1dfd621 feat: Implement Monte Carlo stress-testing for trading strategies; add trade reshuffling and price perturbation simulations 2026-05-18 12:43:11 +03:00
Luke Mosoti 7b21e40345 Refactor XGBoost training and prediction logic; update signal thresholds
- Removed redundant `gmm_vol_cluster` feature from XGBoost training to improve efficiency.
- Adjusted feature selection for bucket models in `train_xgb_ensemble`.
- Updated probability thresholds for trading signals to enhance decision-making.
- Standardized exit confirmation bars for different timeframes in the signal engine.
2026-05-18 11:45:43 +03:00
Luke Mosoti e568a76fd7 refactor: Remove unused TCN parameters from argument parser; update model parameters in JSON and database for improved performance 2026-05-18 09:54:13 +03:00
Luke Mosoti 9cabfd9c49 feat: Enhance backtester logic for intra-bar SL/TP checks and add spread efficiency guard; improve CPCV scoring mechanism in optimizer 2026-05-18 00:47:07 +03:00
Luke Mosoti 40d4a98f1e feat: Update model parameters and thresholds for enhanced performance and stability; implement cooldown mechanism in trading logic 2026-05-18 00:19:23 +03:00
Luke Mosoti 29c5810ca4 fix: Update model parameters and thresholds for improved performance and stability 2026-05-17 22:26:27 +03:00
Luke Mosoti d656d1b672 feat: Enhance CPCV metrics handling and reporting across multiple modules 2026-05-16 22:58:04 +03:00
Luke Mosoti 2af8c2fb0f Refactor guardian and TCN maintenance logic
- Removed TCN staleness checks and auto-retraining from guardian.py.
- Eliminated TCNMaintenanceScheduler and related functions from tcn_maintenance.py.
- Updated mt5_trader.py to remove TCN maintenance checks.
- Adjusted signal_engine.py to remove TCN multiplier logic.
- Cleaned up processor.py by removing optional LSTM context features.
- Modified validation warnings to suggest appropriate periods based on trade counts.
- Updated visualizer.py to streamline signal computation and improve clarity in equity curve plotting.
2026-05-16 22:07:50 +03:00
Luke Mosoti a0758dfe62 feat: Implement two-stage optimization process with XGB exploration
- Added `--stage` argument to `cmd_optimize` for selecting between Stage-1 (XGB exploration) and Stage-2 (CPCV optimization).
- Introduced `run_optimization_stage1` for fast single hold-out XGB trials, significantly improving optimization speed.
- Updated `run_optimization` to support warm-starting from Stage-1 best parameters.
- Enhanced logging with dedicated score logging for trial monitoring.
- Adjusted hyperparameter ranges for XGBoost to allow deeper trees and finer splits.
- Added synthetic VIX feature computation to the feature application process.
- Persisted best parameters from Stage-1 to JSON for future use in Stage-2.
- Updated documentation for new optimization stages and usage instructions.
2026-05-16 20:25:18 +03:00
Luke Mosoti 09adea905e Refactor backtester logic to introduce cooldown mechanism and simplify exit checks
- Added a cooldown period to prevent immediate re-entries after a trade, reducing churn in rapidly oscillating regimes.
- Simplified exit conditions by removing ATR trailing, partial close, and profit guard during optimization.
- Adjusted minimum confirmation bars for H1 to enhance stability before entries and exits.
- Lowered the floor for reg_lambda in optimizer to allow for better HMM state signals.
- Implemented a regime oscillation guard in the CPCV execution to skip paths with excessive transitions, mitigating potential drawdowns.
2026-05-16 12:05:36 +03:00
Luke Mosoti 42c1cb7f7f fix: Correct raw ATR calculation to prevent negative SL/TP distances and improve trade execution logic 2026-05-16 11:21:55 +03:00
Luke Mosoti 329dd0dad5 feat: Update target variable calculation to use future returns over a rolling horizon 2026-05-16 10:32:23 +03:00