Files
xau-ai-trading-bot/backtests/ml_v3/training_log_v3_fixed.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

29 KiB

2026-02-09 16:45:50.084 | INFO | src.mt5_connector:connect:177 - Connected to MT5: FinexBisnisSolusi-Demo (Account: 61045904)
2026-02-09 16:45:50.796 | DEBUG | src.mt5_connector:get_market_data:449 - Fetched 50000 bars for XAUUSD M15
2026-02-09 16:45:51.000 | DEBUG | src.mt5_connector:get_market_data:449 - Fetched 2000 bars for XAUUSD H1
2026-02-09 16:45:51.006 | DEBUG | src.feature_eng:calculate_rsi:130 - RSI calculated (period=14)
2026-02-09 16:45:51.009 | DEBUG | src.feature_eng:calculate_atr:185 - ATR calculated (period=14)
2026-02-09 16:45:51.012 | DEBUG | src.feature_eng:calculate_macd:243 - MACD calculated (12/26/9)
2026-02-09 16:45:51.015 | DEBUG | src.feature_eng:calculate_bollinger_bands:301 - Bollinger Bands calculated (period=20, std=2.0)
2026-02-09 16:45:51.017 | DEBUG | src.feature_eng:calculate_ema_crossover:357 - EMA crossover calculated (9/21)
2026-02-09 16:45:51.019 | DEBUG | src.feature_eng:calculate_volume_features:403 - Volume features calculated (period=20)
2026-02-09 16:45:51.028 | DEBUG | src.feature_eng:calculate_ml_features:518 - ML features calculated
2026-02-09 16:45:51.032 | DEBUG | src.smc_polars:calculate_swing_points:401 - Swing points: 3062 highs, 3079 lows
2026-02-09 16:45:51.035 | DEBUG | src.smc_polars:calculate_fvg:312 - FVG calculation complete. Bullish: 5696, Bearish: 4721
2026-02-09 16:45:51.057 | DEBUG | src.smc_polars:calculate_order_blocks:511 - Order Blocks: 2201 bullish, 2164 bearish
2026-02-09 16:45:51.171 | DEBUG | src.smc_polars:calculate_bos_choch:599 - BOS: 702 bullish, 458 bearish
2026-02-09 16:45:51.171 | DEBUG | src.smc_polars:calculate_bos_choch:600 - CHoCH: 616 bullish, 617 bearish
2026-02-09 16:45:51.375 | INFO | backtests.ml_v2.ml_v2_feature_eng:add_all_v2_features:615 - Adding all V2 features (23 new features)...
2026-02-09 16:45:51.378 | DEBUG | backtests.ml_v2.ml_v2_feature_eng:add_h1_features:233 - H1 features added (8 features)
2026-02-09 16:45:51.385 | DEBUG | backtests.ml_v2.ml_v2_feature_eng:add_continuous_smc_features:410 - Continuous SMC features added (7 features)
2026-02-09 16:45:51.390 | DEBUG | backtests.ml_v2.ml_v2_feature_eng:add_regime_features:497 - Regime features added (4 features)
2026-02-09 16:45:51.396 | DEBUG | backtests.ml_v2.ml_v2_feature_eng:add_price_action_features:593 - Price action features added (4 features)
2026-02-09 16:45:51.397 | INFO | backtests.ml_v2.ml_v2_feature_eng:add_all_v2_features:643 - All V2 features added (23 total)
[I 2026-02-09 16:45:51,589] 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 09:45:00 to 2026-02-09 11:45:00
 
Fetching 2,000 bars of H1 data...
Fetched 2,000 H1 bars
 
Engineering features...
M15 technical indicators...
SMC structure features...
MLV2 features (H1 + derived)...
Total features: 85 (MLV2 compatible)
Columns with nulls: 38
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 (BINARY)...
Starting Triple Barrier Labeling (BINARY: BUY vs SELL)...
Profit target: 0.5 ATR
Stop loss: 0.5 ATR
Max holding: 20 bars
 
Target Distribution (BINARY):
BUY: 27557 (55.14%)
SELL: 22423 (44.86%)
Unlabeled: 20 (last 20 bars)
 
Quality Metrics:
Profit barriers hit: 0 ( 0.00%)
Avg bars to profit: 0.0
Avg return (ATR): 0.000
 
Splitting train/test (stratified, BINARY)...
Train: 39,985 samples
Test: 9,995 samples
Train distribution: BUY=55.1%, SELL=44.9%
Test distribution: BUY=55.1%, SELL=44.9%
 
Balancing TRAINING set only (BINARY)...
 
Balancing Classes (BINARY)...
Target distribution: BUY=50%, SELL=50%
Before: BUY=22046, SELL=17939
After: BUY=17939, SELL=17939
Total samples: 35878
 
Selected 81 features
Sample features: spread, rsi, atr, atr_percent, macd, macd_signal, macd_histogram, bb_middle, bb_upper, bb_lower...
 
Training XGBoost model (BINARY: BUY vs SELL)...
Training classes: [0 1] (expected: [0, 1])
Class weights: SELL=1.00, BUY=1.00
Class distribution: SELL=17939 (50.0%), BUY=17939 (50.0%)
Running Optuna hyperparameter optimization...
[I 2026-02-09 16:45:57,764] Trial 0 finished with value: 0.5372686343171585 and parameters: {'max_depth': 6, 'learning_rate': 0.01755557651470559, 'n_estimators': 400, 'min_child_weight': 4, 'gamma': 0.07092610329933297, 'subsample': 0.8072614274939443, 'colsample_bytree': 0.8473492681262139, 'reg_alpha': 0.4656894628839471, 'reg_lambda': 0.7562746800910303}. Best is trial 0 with value: 0.5372686343171585.
[I 2026-02-09 16:46:06,403] Trial 1 finished with value: 0.5254627313656829 and parameters: {'max_depth': 7, 'learning_rate': 0.168880753714888, 'n_estimators': 350, 'min_child_weight': 1, 'gamma': 0.05000056083472754, 'subsample': 0.8414965649141212, 'colsample_bytree': 0.9771297734542507, 'reg_alpha': 0.4745084731363527, 'reg_lambda': 0.14857041059054654}. Best is trial 0 with value: 0.5372686343171585.
[I 2026-02-09 16:46:15,652] Trial 2 finished with value: 0.5508754377188594 and parameters: {'max_depth': 8, 'learning_rate': 0.013676043223331198, 'n_estimators': 300, 'min_child_weight': 5, 'gamma': 0.021238255646964077, 'subsample': 0.8604386118620899, 'colsample_bytree': 0.8744531988988875, 'reg_alpha': 0.549016360970928, 'reg_lambda': 0.8558917982994838}. Best is trial 2 with value: 0.5508754377188594.
[I 2026-02-09 16:46:21,496] Trial 3 finished with value: 0.543671835917959 and parameters: {'max_depth': 5, 'learning_rate': 0.12265851379408758, 'n_estimators': 400, 'min_child_weight': 6, 'gamma': 0.31685121892503115, 'subsample': 0.861168642793601, 'colsample_bytree': 0.8896788161042266, 'reg_alpha': 0.0360636253794, 'reg_lambda': 0.719899561481671}. Best is trial 2 with value: 0.5508754377188594.
[I 2026-02-09 16:46:30,411] Trial 4 finished with value: 0.5431715857928965 and parameters: {'max_depth': 7, 'learning_rate': 0.061829499622131356, 'n_estimators': 350, 'min_child_weight': 2, 'gamma': 0.4403041912672776, 'subsample': 0.7889201148936328, 'colsample_bytree': 0.7620300004806546, 'reg_alpha': 0.3163443508158479, 'reg_lambda': 1.0829268731254469}. Best is trial 2 with value: 0.5508754377188594.
[I 2026-02-09 16:46:36,185] Trial 5 finished with value: 0.5431715857928965 and parameters: {'max_depth': 5, 'learning_rate': 0.011778928976842873, 'n_estimators': 350, 'min_child_weight': 7, 'gamma': 0.30380002046454735, 'subsample': 0.9969557235246403, 'colsample_bytree': 0.8373253027199772, 'reg_alpha': 0.3158295335034127, 'reg_lambda': 0.3957076130181003}. Best is trial 2 with value: 0.5508754377188594.
[I 2026-02-09 16:46:45,088] Trial 6 finished with value: 0.5421710855427714 and parameters: {'max_depth': 7, 'learning_rate': 0.01135070074234482, 'n_estimators': 350, 'min_child_weight': 4, 'gamma': 0.023740830428984283, 'subsample': 0.8015396253807192, 'colsample_bytree': 0.9511007061779484, 'reg_alpha': 0.3537458847176086, 'reg_lambda': 1.2629407325986308}. Best is trial 2 with value: 0.5508754377188594.
[I 2026-02-09 16:46:48,765] Trial 7 finished with value: 0.552976488244122 and parameters: {'max_depth': 5, 'learning_rate': 0.015118327453507604, 'n_estimators': 200, 'min_child_weight': 3, 'gamma': 0.3418528927639189, 'subsample': 0.8674028615450962, 'colsample_bytree': 0.8196161026507331, 'reg_alpha': 0.9710830793723528, 'reg_lambda': 0.7441504601064461}. Best is trial 7 with value: 0.552976488244122.
[I 2026-02-09 16:46:54,118] Trial 8 finished with value: 0.5435717858929465 and parameters: {'max_depth': 4, 'learning_rate': 0.020445044494546993, 'n_estimators': 450, 'min_child_weight': 2, 'gamma': 0.4799667742560567, 'subsample': 0.6250481465137108, 'colsample_bytree': 0.6173434142285082, 'reg_alpha': 0.4569285054585679, 'reg_lambda': 0.6438877902945772}. Best is trial 7 with value: 0.552976488244122.
[I 2026-02-09 16:46:58,180] Trial 9 finished with value: 0.535767883941971 and parameters: {'max_depth': 3, 'learning_rate': 0.09885956574247975, 'n_estimators': 350, 'min_child_weight': 4, 'gamma': 0.49315648553926994, 'subsample': 0.7194852375035138, 'colsample_bytree': 0.915245646179611, 'reg_alpha': 0.11893364631154602, 'reg_lambda': 0.9939723409230117}. Best is trial 7 with value: 0.552976488244122.
[I 2026-02-09 16:47:00,244] Trial 10 finished with value: 0.5547773886943472 and parameters: {'max_depth': 3, 'learning_rate': 0.031095899971443988, 'n_estimators': 150, 'min_child_weight': 3, 'gamma': 0.18577091170191, 'subsample': 0.979435903355256, 'colsample_bytree': 0.7438985052480047, 'reg_alpha': 0.9410013939796988, 'reg_lambda': 1.7882675952078875}. Best is trial 10 with value: 0.5547773886943472.
[I 2026-02-09 16:47:02,339] Trial 11 finished with value: 0.5536768384192096 and parameters: {'max_depth': 3, 'learning_rate': 0.0329139166742609, 'n_estimators': 150, 'min_child_weight': 3, 'gamma': 0.1723861746966001, 'subsample': 0.9841571938941059, 'colsample_bytree': 0.7440834167339366, 'reg_alpha': 0.9874954559148768, 'reg_lambda': 1.8939533162205724}. Best is trial 10 with value: 0.5547773886943472.
[I 2026-02-09 16:47:04,155] Trial 12 finished with value: 0.560280140070035 and parameters: {'max_depth': 3, 'learning_rate': 0.03311362565418044, 'n_estimators': 100, 'min_child_weight': 3, 'gamma': 0.16116924825633608, 'subsample': 0.9998914960198222, 'colsample_bytree': 0.7232805919454712, 'reg_alpha': 0.9816702791466874, 'reg_lambda': 1.9562951126784363}. Best is trial 12 with value: 0.560280140070035.
[I 2026-02-09 16:47:05,913] Trial 13 finished with value: 0.5614807403701851 and parameters: {'max_depth': 3, 'learning_rate': 0.03340286383975731, 'n_estimators': 100, 'min_child_weight': 2, 'gamma': 0.1665494798542183, 'subsample': 0.9351667442030648, 'colsample_bytree': 0.6737792517742777, 'reg_alpha': 0.7804430783635491, 'reg_lambda': 1.9822496346577494}. Best is trial 13 with value: 0.5614807403701851.
[I 2026-02-09 16:47:07,716] Trial 14 finished with value: 0.5358679339669835 and parameters: {'max_depth': 4, 'learning_rate': 0.053760021194810326, 'n_estimators': 100, 'min_child_weight': 1, 'gamma': 0.12990802941246746, 'subsample': 0.9280883580344288, 'colsample_bytree': 0.6456039506723489, 'reg_alpha': 0.7718332533356731, 'reg_lambda': 1.6080980203984012}. Best is trial 13 with value: 0.5614807403701851.
[I 2026-02-09 16:47:10,562] Trial 15 finished with value: 0.5389694847423712 and parameters: {'max_depth': 4, 'learning_rate': 0.03321724346100841, 'n_estimators': 200, 'min_child_weight': 2, 'gamma': 0.22250550562480909, 'subsample': 0.9249560508315149, 'colsample_bytree': 0.6803485541827908, 'reg_alpha': 0.770259053880076, 'reg_lambda': 1.5014360491197363}. Best is trial 13 with value: 0.5614807403701851.
[I 2026-02-09 16:47:12,185] Trial 16 finished with value: 0.568784392196098 and parameters: {'max_depth': 3, 'learning_rate': 0.02372312562116949, 'n_estimators': 100, 'min_child_weight': 1, 'gamma': 0.10654204697811255, 'subsample': 0.9364174432522089, 'colsample_bytree': 0.7031796673225155, 'reg_alpha': 0.7974351847252932, 'reg_lambda': 1.9804942417034694}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:15,809] Trial 17 finished with value: 0.5381690845422711 and parameters: {'max_depth': 4, 'learning_rate': 0.021615361484380372, 'n_estimators': 250, 'min_child_weight': 1, 'gamma': 0.10388153369057004, 'subsample': 0.9230995056950458, 'colsample_bytree': 0.6853503080693842, 'reg_alpha': 0.7137270538098834, 'reg_lambda': 1.4556810941411245}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:17,657] Trial 18 finished with value: 0.5332666333166584 and parameters: {'max_depth': 3, 'learning_rate': 0.06559888316593436, 'n_estimators': 100, 'min_child_weight': 2, 'gamma': 0.26318368336359577, 'subsample': 0.7325003826564399, 'colsample_bytree': 0.6085841264451994, 'reg_alpha': 0.6503707703597295, 'reg_lambda': 1.6975242835178586}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:21,931] Trial 19 finished with value: 0.5412706353176588 and parameters: {'max_depth': 6, 'learning_rate': 0.024313334425092394, 'n_estimators': 200, 'min_child_weight': 1, 'gamma': 0.10262898139458487, 'subsample': 0.9022918379456697, 'colsample_bytree': 0.7876476609582218, 'reg_alpha': 0.861599431Best trial: 16. Best value: 0.568784: 100%|##########| 30/30 [01:58<00:00, 3.95s/it]96098.
 
[I 2026-02-09 16:47:25,074] Trial 20 finished with value: 0.5370685342671335 and parameters: {'max_depth': 4, 'learning_rate': 0.04352508218695565, 'n_estimators': 150, 'min_child_weight': 2, 'gamma': 0.23267054813701996, 'subsample': 0.9546673084828781, 'colsample_bytree': 0.6934168046819972, 'reg_alpha': 0.6241217242244527, 'reg_lambda': 1.9971863792210254}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:26,977] Trial 21 finished with value: 0.5623811905952977 and parameters: {'max_depth': 3, 'learning_rate': 0.03902012100873866, 'n_estimators': 100, 'min_child_weight': 3, 'gamma': 0.1586501356901509, 'subsample': 0.9547854344032023, 'colsample_bytree': 0.7129491750593099, 'reg_alpha': 0.8398138251281323, 'reg_lambda': 1.9854259519258644}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:28,707] Trial 22 finished with value: 0.551575787893947 and parameters: {'max_depth': 3, 'learning_rate': 0.04310126180495365, 'n_estimators': 100, 'min_child_weight': 3, 'gamma': 0.13796693384205214, 'subsample': 0.89877281749946, 'colsample_bytree': 0.6634269122515914, 'reg_alpha': 0.834668464837715, 'reg_lambda': 1.7761926933288252}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:31,232] Trial 23 finished with value: 0.5465732866433216 and parameters: {'max_depth': 4, 'learning_rate': 0.02486526327484417, 'n_estimators': 150, 'min_child_weight': 1, 'gamma': 0.20621157124216746, 'subsample': 0.9602163617633142, 'colsample_bytree': 0.7168301671883803, 'reg_alpha': 0.8513557758841518, 'reg_lambda': 1.5952366185435096}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:33,989] Trial 24 finished with value: 0.5456728364182091 and parameters: {'max_depth': 3, 'learning_rate': 0.07419465575770377, 'n_estimators': 250, 'min_child_weight': 2, 'gamma': 0.27397233145703964, 'subsample': 0.948100613582829, 'colsample_bytree': 0.6402037449550099, 'reg_alpha': 0.6627032729746859, 'reg_lambda': 1.8535663708495806}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:38,846] Trial 25 finished with value: 0.5341670835417709 and parameters: {'max_depth': 3, 'learning_rate': 0.04521565498683209, 'n_estimators': 500, 'min_child_weight': 5, 'gamma': 0.09280277787631178, 'subsample': 0.8966182942730149, 'colsample_bytree': 0.7804790288264897, 'reg_alpha': 0.8900289937945495, 'reg_lambda': 1.986904982622233}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:40,663] Trial 26 finished with value: 0.551575787893947 and parameters: {'max_depth': 4, 'learning_rate': 0.027369103415142915, 'n_estimators': 100, 'min_child_weight': 2, 'gamma': 0.3747227992197878, 'subsample': 0.6202599102302417, 'colsample_bytree': 0.707376310461279, 'reg_alpha': 0.761247932711477, 'reg_lambda': 1.7066731425207464}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:43,144] Trial 27 finished with value: 0.543871935967984 and parameters: {'max_depth': 5, 'learning_rate': 0.03974698990750001, 'n_estimators': 150, 'min_child_weight': 5, 'gamma': 0.1542868245011073, 'subsample': 0.832561100797325, 'colsample_bytree': 0.6514207678712729, 'reg_alpha': 0.5760724419781813, 'reg_lambda': 1.2552930352343137}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:46,241] Trial 28 finished with value: 0.5437718859429714 and parameters: {'max_depth': 3, 'learning_rate': 0.018115967291782456, 'n_estimators': 250, 'min_child_weight': 1, 'gamma': 0.06553882520878107, 'subsample': 0.7621754035493635, 'colsample_bytree': 0.7491928985672744, 'reg_alpha': 0.6989518801129243, 'reg_lambda': 1.415601916289535}. Best is trial 16 with value: 0.568784392196098.
[I 2026-02-09 16:47:50,127] Trial 29 finished with value: 0.5466733366683342 and parameters: {'max_depth': 6, 'learning_rate': 0.08579526411662486, 'n_estimators': 200, 'min_child_weight': 4, 'gamma': 0.19524647174222595, 'subsample': 0.8825448014567417, 'colsample_bytree': 0.7190621127935031, 'reg_alpha': 0.8028569696676869, 'reg_lambda': 1.6354388849194612}. Best is trial 16 with value: 0.568784392196098.
 
Best trial: 16
Best accuracy: 0.5688
 
Training final model with params: {'max_depth': 3, 'learning_rate': 0.02372312562116949, 'n_estimators': 100, 'min_child_weight': 1, 'gamma': 0.10654204697811255, 'subsample': 0.9364174432522089, 'colsample_bytree': 0.7031796673225155, 'reg_alpha': 0.7974351847252932, 'reg_lambda': 1.9804942417034694}
 
Model Performance (BINARY):
Train Accuracy: 0.5739
Test Accuracy: 0.5631
 
Test Set Classification Report (BINARY):
precision recall f1-score support
 
SELL 0.511 0.591 0.548 4484
BUY 0.619 0.540 0.577 5511
 
accuracy 0.563 9995
macro avg 0.565 0.566 0.563 9995
weighted avg 0.571 0.563 0.564 9995
 
 
Confusion Matrix:
Predicted
SELL BUY
SELL 2650 1834
BUY 2533 2978
 
Model saved to: backtests\ml_v3\xgboost_model_v3.pkl (TradingModelV2 format)
Metadata saved to: backtests\ml_v3\xgboost_model_v3_metadata.json
 
================================================================================
TRAINING COMPLETE
================================================================================