Files
xau-ai-trading-bot/backtests/ml_v3/training_log.txt
T
buckybonez c0976c4518 feat: implement Professor AI recommendations v0.2.2 (5 critical fixes)
Exit Strategy v6.6 "Professor AI Validated" - All recommendations implemented

FIX #1: Remove Misleading Debug Code
- Removed manual trajectory calculation (line 1262-1269)
- Trajectory predictor was CORRECT, debug comparison was WRONG
- Cleaned up false "bug found" warnings

FIX #2: Peak Detection Logic (CHECK 0A.4)
- Detects approaching peak (vel > 0, accel < 0)
- Holds position if peak within 30s and 15%+ profit ahead
- Suppresses fuzzy exits during peak approach
- Target: Peak capture 38% -> 70%+
- Added peak_hold_active field to PositionGuard

FIX #3: London False Breakout Filter
- London session + ATR ratio < 1.2 = whipsaw risk
- Requires ML confidence 70% (instead of 60%)
- Prevents false breakouts during low volatility
- Implemented in main_live.py before signal logic

FIX #4: Enhanced Kelly Partial Exit Strategy
- Active for all profits >= tp_min * 0.5 (not just >$8)
- Recommends partial exits for better peak capture
- Full exit when Kelly suggests >70% close
- Note: Actual partial close needs MT5 volume parameter (TODO)

FIX #5: Unicode Encoding Fixes
- Added UTF-8 encoding to file logger
- Replaced all emoji (⚠️ -> [WARNING]) and arrows (-> -> ->)
- No more UnicodeEncodeError on Windows console
- Fixed in 11 src/*.py files

Expected Performance:
- Peak Capture: 38% -> 70%+ (+84%)
- Avg Profit: $2.00 -> $4.50 (+125%)
- Risk/Reward: 0.49 -> 1.2+ (+145%)
- Win Rate: Maintain 76%

Files Modified:
- src/smart_risk_manager.py (peak detection, Kelly, unicode)
- src/trajectory_predictor.py (unicode arrows)
- main_live.py (London filter, UTF-8 encoding)
- src/*.py (unicode cleanup: 11 files)
- VERSION (0.2.1 -> 0.2.2)
- CHANGELOG.md (comprehensive v0.2.2 docs)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 18:16:34 +07:00

10 KiB

2026-02-09 15:42:36.061 | INFO | src.mt5_connector:connect:177 - Connected to MT5: FinexBisnisSolusi-Demo (Account: 61045904)
2026-02-09 15:42:36.795 | DEBUG | src.mt5_connector:get_market_data:449 - Fetched 50000 bars for XAUUSD M15
2026-02-09 15:42:37.000 | DEBUG | src.mt5_connector:get_market_data:449 - Fetched 2000 bars for XAUUSD H1
2026-02-09 15:42:37.009 | DEBUG | src.feature_eng:calculate_rsi:130 - RSI calculated (period=14)
2026-02-09 15:42:37.012 | DEBUG | src.feature_eng:calculate_atr:185 - ATR calculated (period=14)
2026-02-09 15:42:37.015 | DEBUG | src.feature_eng:calculate_macd:243 - MACD calculated (12/26/9)
2026-02-09 15:42:37.018 | DEBUG | src.feature_eng:calculate_bollinger_bands:301 - Bollinger Bands calculated (period=20, std=2.0)
2026-02-09 15:42:37.020 | DEBUG | src.feature_eng:calculate_ema_crossover:357 - EMA crossover calculated (9/21)
2026-02-09 15:42:37.022 | DEBUG | src.feature_eng:calculate_volume_features:403 - Volume features calculated (period=20)
2026-02-09 15:42:37.032 | DEBUG | src.feature_eng:calculate_ml_features:518 - ML features calculated
2026-02-09 15:42:37.036 | DEBUG | src.smc_polars:calculate_swing_points:401 - Swing points: 3062 highs, 3079 lows
2026-02-09 15:42:37.038 | DEBUG | src.smc_polars:calculate_fvg:312 - FVG calculation complete. Bullish: 5696, Bearish: 4720
2026-02-09 15:42:37.061 | DEBUG | src.smc_polars:calculate_order_blocks:511 - Order Blocks: 2201 bullish, 2164 bearish
2026-02-09 15:42:37.169 | DEBUG | src.smc_polars:calculate_bos_choch:599 - BOS: 702 bullish, 458 bearish
2026-02-09 15:42:37.169 | DEBUG | src.smc_polars:calculate_bos_choch:600 - CHoCH: 616 bullish, 617 bearish
2026-02-09 15:42:37.171 | DEBUG | src.feature_eng:calculate_rsi:130 - RSI calculated (period=14)
2026-02-09 15:42:37.173 | DEBUG | src.feature_eng:calculate_atr:185 - ATR calculated (period=14)
2026-02-09 15:42:37.174 | DEBUG | src.feature_eng:calculate_macd:243 - MACD calculated (12/26/9)
2026-02-09 15:42:37.175 | DEBUG | src.feature_eng:calculate_bollinger_bands:301 - Bollinger Bands calculated (period=20, std=2.0)
2026-02-09 15:42:37.176 | DEBUG | src.feature_eng:calculate_ema_crossover:357 - EMA crossover calculated (9/21)
2026-02-09 15:42:37.177 | DEBUG | src.feature_eng:calculate_volume_features:403 - Volume features calculated (period=20)
2026-02-09 15:42:37.178 | DEBUG | src.smc_polars:calculate_swing_points:401 - Swing points: 130 highs, 130 lows
2026-02-09 15:42:37.179 | DEBUG | src.smc_polars:calculate_fvg:312 - FVG calculation complete. Bullish: 256, Bearish: 155
2026-02-09 15:42:37.181 | DEBUG | src.smc_polars:calculate_order_blocks:511 - Order Blocks: 90 bullish, 82 bearish
2026-02-09 15:42:37.187 | DEBUG | src.smc_polars:calculate_bos_choch:599 - BOS: 39 bullish, 20 bearish
2026-02-09 15:42:37.187 | DEBUG | src.smc_polars:calculate_bos_choch:600 - CHoCH: 19 bullish, 19 bearish
[I 2026-02-09 15:42:37,440] A new study created in memory with name: xgboost_opt
================================================================================
ML MODEL V3 TRAINING PIPELINE
Bismillah - Building Exceptional Model
================================================================================
 
Fetching 50,000 bars of M15 data...
Symbol: XAUUSD
Timeframe: M15
Fetched 50,000 bars
Date range: 2023-12-27 08:30:00 to 2026-02-09 10:30:00
 
Fetching 2,000 bars of H1 data...
Fetched 2,000 H1 bars
 
Engineering features...
M15 technical indicators...
SMC structure features...
H1 higher timeframe features...
Total features: 70
Columns with nulls: 45
rsi, atr, atr_percent, bb_middle, bb_upper, bb_lower, bb_width, bb_percent_b, volume_sma, volume_ratio
Filling nulls with forward fill...
 
Labeling data with Triple Barrier Method...
Starting Triple Barrier Labeling...
Profit target: 0.2 ATR
Stop loss: 0.15 ATR
Max holding: 8 bars
Min move threshold: 0.1 ATR
 
Target Distribution:
BUY: 35687 (71.37%)
SELL: 14292 (28.58%)
HOLD: 21 ( 0.04%)
 
Quality Metrics:
Profit barriers hit: 0 ( 0.00%)
Avg bars to profit: 0.0
Avg return (ATR): 0.000
 
Balancing Classes...
Target distribution: BUY=32%, SELL=32%, HOLD=36%
Before: BUY=35687, SELL=14292, HOLD=21
After: BUY=14291, SELL=14291, HOLD=21
Total samples: 28603
 
Splitting train/test...
Train: 22,883 samples
Test: 5,720 samples
Test period: 2023-12-27 08:30:00 to 2026-02-09 10:30:00
Train distribution: BUY=62.5%, SELL=37.5%, HOLD=0.0%
Test distribution: BUY=0.0%, SELL=99.6%, HOLD=0.4%
 
Selected 69 features
Sample features: spread, rsi, atr, atr_percent, macd, macd_signal, macd_histogram, bb_middle, bb_upper, bb_lower...
 
Training XGBoost model...
Class weights: SELL=0.89, HOLD=1.00, BUY=0.53
Running Optuna hyperparameter optimization...
0%| | 0/30 [00:00<?, ?it/s]
Traceback (most recent call last):
File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 580, in <module>
trainer.run_full_pipeline()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 565, in run_full_pipeline
model = self.train_xgboost(df_train, df_test, feature_cols, optimize_hyperparams=True)
File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 377, in train_xgboost
best_params = self._optimize_hyperparameters(
X_train, y_train_mc, X_test, y_test_mc, sample_weights
)
File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 505, in _optimize_hyperparameters
study.optimize(objective, n_trials=30, show_progress_bar=True, n_jobs=1)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python313\Lib\site-packages\optuna\study\study.py", line 490, in optimize
_optimize(
~~~~~~~~~^
study=self,
^^^^^^^^^^^
...<7 lines>...
show_progress_bar=show_progress_bar,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\Python313\Lib\site-packages\optuna\study\_optimize.py", line 68, in _optimize
_optimize_sequential(
~~~~~~~~~~~~~~~~~~~~^
study,
^^^^^^
...<8 lines>...
progress_bar=progress_bar,
^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\Python313\Lib\site-packages\optuna\study\_optimize.py", line 165, in _optimize_sequential
frozen_trial_id = _run_trial(study, func, catch)
File "C:\Python313\Lib\site-packages\optuna\study\_optimize.py", line 263, in _run_trial
raise func_err
File "C:\Python313\Lib\site-packages\optuna\study\_optimize.py", line 206, in _run_trial
value_or_values = func(trial)
File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 498, in objective
model.fit(X_train, y_train, sample_weight=sample_weights, verbose=False)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python313\Lib\site-packages\xgboost\core.py", line 774, in inner_f
return func(**kwargs)
File "C:\Python313\Lib\site-packages\xgboost\sklearn.py", line 1763, in fit
raise ValueError(
...<2 lines>...
)
ValueError: Invalid classes inferred from unique values of `y`. Expected: [0 1], got [0 2]
[W 2026-02-09 15:42:37,448] Trial 0 failed with parameters: {'max_depth': 3, 'learning_rate': 0.13047455532390495, 'n_estimators': 500, 'min_child_weight': 6, 'gamma': 0.4227292711890863, 'subsample': 0.6486036877331404, 'colsample_bytree': 0.6421699904554006, 'reg_alpha': 0.7032937095957577, 'reg_lambda': 0.9601028148259148} because of the following error: ValueError('Invalid classes inferred from unique values of `y`. Expected: [0 1], got [0 2]').
Traceback (most recent call last):
File "C:\Python313\Lib\site-packages\optuna\study\_optimize.py", line 206, in _run_trial
value_or_values = func(trial)
File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 498, in objective
model.fit(X_train, y_train, sample_weight=sample_weights, verbose=False)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python313\Lib\site-packages\xgboost\core.py", line 774, in inner_f
return func(**kwargs)
File "C:\Python313\Lib\site-packages\xgboost\sklearn.py", line 1763, in fit
raise ValueError(
...<2 lines>...
)
ValueError: Invalid classes inferred from unique values of `y`. Expected: [0 1], got [0 2]
[W 2026-02-09 15:42:37,515] Trial 0 failed with value None.
 
Training failed: Invalid classes inferred from unique values of `y`. Expected: [0 1], got [0 2]