10 Commits

Author SHA1 Message Date
Vanszs 82d010fcf2 fix: remove leaked models + add honest data/backtest tooling
- Delete all old XGBoost/HMM models trained with the order-block look-ahead
  leak (models/backups/* + root models). They reproduced a fake 63.9% WR /
  2.64 PF that collapses to ~35% WR / 0.95 PF once the leak is fixed.
- scripts/collect_data.py: dedicated raw M1+M15 collector (paginated)
- scripts/fast_backtest.py: vectorized GPU backtest for honest validation
- backtest_live_sync.py: read SYMBOL from env (XM uses GOLD, not XAUUSD)
- stop tracking generated data/training_data.parquet

See upstream report: GifariKemal/xaubot-ai#4
2026-06-06 18:21:50 +07:00
Vanszs a4619dd005 chore: clean up workspace for production
- Remove tracked generated artifacts: backtest logs (52), xlsx (43),
  experiment model pkls (7), ml_v3 training logs (11), result csv/txt
- Remove junk files: stray =1.4.5, training_output.log, *_analysis_output.txt,
  dead api.log, runtime bot.lock
- Remove throwaway scripts: analyze_performance, test_trajectory_bug, verify_settings
- Move reusable analysis scripts to scripts/analysis/
- Move status/report docs to docs/reports/
- Tighten .gitignore to prevent re-adding generated artifacts; ignore .kiro/
2026-06-06 12:04:13 +07:00
GifariKemal 0f9548e5fb 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
GifariKemal 4626f2a295 chore: add backtest #39 and HMM investigation artifacts
Added research artifacts from HMM investigation:
- backtest_39_h1_hmm.py — H1 vs M15 HMM comparison attempt
- 39_h1_hmm_results/ — Partial backtest results
- analyze_*.py — ML model and H1 feature analysis scripts
- *_output.txt — Analysis outputs showing HMM degeneracy

Updated:
- data/risk_state.txt — Latest risk state (daily_loss: 18.77, daily_profit: 22.49)

Note: Backtest #39 had import compatibility issues but led to critical
discovery of alternating HMM pattern bug (fixed in c02c2e9).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-09 10:51:49 +07:00
GifariKemal e8355b3f62 feat: add 5 dashboard features — dark mode, trade history, backtests, model insights, alerts
- Dark mode: class-based theme toggle with localStorage persistence and flash prevention
- Trade History (/trades): paginated table, stats cards, equity curve chart with DB API endpoints
- Backtest Viewer (/backtests): log parser for 35 backtest results, sidebar + detail + comparison tabs
- Model Insights: dashboard card + dialog showing feature importance, regime distribution, training history
- Alert/Signal Log (/alerts): signal stats, filterable table with execution tracking
- API: 8 new endpoints with psycopg2 DB connection pool
- Dark mode sweep across books page, about dialog, and all dashboard components
- Architecture docs rewritten with Mermaid diagrams (23 docs)
- README and FEATURES.md rewritten bilingual (Indonesian + English)
- main_live.py: write model_metrics.json on startup and retrain

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 05:46:54 +07:00
GifariKemal cb41bfe5ba feat: apply #33B impulse trail + #34A skip hours 9,21 WIB
#33B Impulse Trail (position_manager.py):
- Tighten trailing SL to 1.5x ATR when candle range > 1.5x ATR
- Locks profit faster during volatile spikes (+$59, Sharpe 4.03)

#34A Time-of-Hour Filter (main_live.py):
- Skip entries at WIB hours 9 (02:00 UTC) and 21 (14:00 UTC)
- Hour 9 = end NY session (low liquidity), Hour 21 = London-NY transition (whipsaw)
- +$356 vs #31B, WR 82.6%, Sharpe 4.41, PF 2.43, DD 2.4%

Cumulative live: $3,163 net, 614 trades, 82.6% WR, Sharpe 4.41

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 12:55:34 +07:00
GifariKemal 214b64945d feat: apply #28B smart breakeven + #31B H1 EMA20 filter, add backtests #26-#32
Live trading optimizations (cumulative: $2,807 net, 81.8% WR, Sharpe 3.97):
- #28B: Smart breakeven locks profit at entry + 0.5x ATR instead of fixed $2
- #31B: H1 Price vs EMA20 filter — BUY only when H1 bullish, SELL only when bearish

Backtests #26-#32 (7 scripts testing sell improvement, regime-aware entry,
confluence scoring, dynamic RR, multi-TF H1, and ML exit optimizer).
Winners: #28B (+$229), #31B (+$343). Failed: #26, #27, #29, #30, #32.

Also includes: web dashboard redesign, Docker setup, startup scripts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 10:33:24 +07:00
GifariKemal 20dc1385c3 optimize: improve win rate with SELL filter and reduced cooldown
Changes:
- Add SELL filter: require ML agreement + 55% confidence for SELL signals
- Reduce trade cooldown: 300s -> 150s (more trade opportunities)
- Relax trend reversal threshold: 0.4 -> 0.6 (less premature exits)
- backtest_live_sync.py: add configurable params for optimization testing

Backtest Results (Jan 2025 - Feb 2026):
BASELINE: 535 trades, 44.1% WR, $994 profit, PF 1.31
OPTIMIZED: 459 trades, 49.2% WR, $1018 profit, PF 1.43

Improvements:
- Win Rate: +5.1% (44.1% -> 49.2%)
- Profit Factor: +0.12 (1.31 -> 1.43)
- Max Drawdown: -0.8% (5.7% -> 4.9%)
- Sharpe Ratio: +0.55 (1.28 -> 1.83)
- NY Session WR: +17.4% (41.6% -> 59.0%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 11:46:36 +07:00
GifariKemal d99df49dfc sync: backtest_live_sync.py with all critical/major fixes
Synchronized elements:
- ATR-based pullback filter (no more hardcoded $2, $1.5)
- Smart time-based exit (checks profit_growing before exit)
- ATR-based trend reversal thresholds
- Signal persistence with index-based cleanup
- Matches main_live.py logic 100%

Backtest Results (Jan 2025 - Feb 2026):
- 534 trades, 44.2% WR
- Net P/L: +$1,056.94
- Profit Factor: 1.34
- Max Drawdown: 5.7%
- Expectancy: +$1.98/trade

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 10:25:17 +07:00
GifariKemal 7af9183af3 feat: Smart AI Trading Bot for XAUUSD with ML and SMC
- XGBoost ML model with 37 features for market direction prediction
- Smart Money Concepts (SMC): Order Blocks, FVG, BOS, CHoCH
- HMM market regime detection (trending/ranging/volatile)
- ATR-based stop loss with 1.5 ATR minimum distance
- Broker-level SL protection with fallback
- Time-based exit (max 6 hours per trade)
- Session-aware trading optimized for London/NY overlap
- Auto-retraining based on market conditions
- Telegram notifications and web dashboard
- Backtest results: 63.9% win rate, 2.64 profit factor, 4.83 Sharpe

Backtest period: Jan 2025 - Feb 2026, 654 trades, $4,189 net P/L

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 09:01:35 +07:00