session_name variable not in scope at line 1716.
Get current session from session_filter.get_status_report() instead.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Night Safety blocked trades at 57 pips spread during Golden Session.
Golden Session has extreme volatility, spread 50-80 pips is normal.
Change: Golden Session night spread limit 50 → 80 pips
Normal night hours remain 50 pips limit.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix#3: Grace period capped at 2min for trades that NEVER saw profit
- Fix#4: effective_max_loss and max_atr_loss can only tighten (monotonic)
- Golden Session: loss_mult*0.70, profit_mult*0.85, grace*0.60
- market_context now includes is_golden, session_name, session_volatility
- Enhanced dynamic log with [GOLDEN] tag, ratchet values, ever_profitable
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CRITICAL FIX: v0.2.3 was still blocking SMC signals!
Problem:
- v0.2.3 had 3-tier logic that BLOCKS SMC 60-75% if ML disagrees
- Signal BUY 63% + ML HOLD 50% was BLOCKED (wrong!)
- Original v4 intention: SMC-only, ML for boost only
Root Cause:
- v0.2.3 logic still required ML agreement for medium tier
- This contradicts "SMC patokan utama, ML pendukung"
Solution v0.2.4:
- Single threshold: SMC >= 55% executes ALWAYS
- ML role: OPTIONAL boost (average) or ignored
- SELL filter: Only exception (requires ML >= 75%)
- No more tiers, no more ML blocking
Impact:
- SMC BUY 63% + ML HOLD → Now EXECUTES (was blocked)
- True SMC-only mode restored
- ML is reference/boost only
Files:
- main_live.py: Logic v6 (SMC-only)
- VERSION: 0.2.3 → 0.2.4
- CHANGELOG.md: Full documentation
User feedback: "Perasaan tadi sebelum perbaikan, kita
mengabaikan ML dan fokus SMC saja" - NOW CORRECT!
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
PHILOSOPHY: SMC = PRIMARY, ML = SECONDARY support (not blocker)
Changes:
1. London Filter: Penalty (10%) instead of block
- Before: Block trade if ML < 70% confidence
- After: Reduce confidence by 10%, still execute
2. Signal Logic v5: 3-tier SMC-primary hierarchy
- SMC >= 75%: Execute always (ML optional boost)
- SMC 60-75%: Require ML agreement
- SMC < 60%: Skip (low conviction)
3. Removed SELL confidence filter
- SMC confidence now determines execution
- No more blanket blocking of SELL signals
Impact:
- High SMC confidence trades (75-85%) execute
- No blocking from ML HOLD predictions
- ML still boosts when agrees
- Addresses user feedback: "SMC patokan utama, ML pendukung"
Files:
- main_live.py: Signal aggregation logic rewritten
- VERSION: 0.2.2 -> 0.2.3
- CHANGELOG.md: Full documentation
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
NameError: name 'df' is not defined
Line 1920: if 'atr' in df.columns:
Fixed to: cached_df = getattr(self, '_cached_df', None)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement industrial-standard semantic versioning (SemVer 2.0.0) with
automated feature detection and comprehensive changelog management.
New Features:
- VERSION file: Single source of truth for base version (0.0.0)
- src/version.py: Centralized version manager with auto-detection
- CHANGELOG.md: Keep a Changelog format for all changes
- Auto-versioning: Features increment MINOR version automatically
- Version display: Shows in startup banner and logs
Predictive Intelligence (v6.3) Complete:
- src/trajectory_predictor.py: Forecast profit 1-5 minutes ahead
- src/momentum_persistence.py: Detect momentum continuation (0-1 score)
- src/recovery_detector.py: Analyze recovery strength from losses
- src/fuzzy_exit_logic.py: Fuzzy logic exit confidence (0-1)
- src/kalman_filter.py: Kalman filter for velocity smoothing
- src/kelly_position_scaler.py: Kelly criterion position scaling
Version Calculation:
Base 0.0.0 + Kalman(0.1) + Fuzzy(0.1) + Kelly(0.1) +
Trajectory(0.1) + Momentum(0.1) + Recovery(0.1) = v0.6.0
Modified:
- CLAUDE.md: Added comprehensive versioning documentation
- main_live.py: Display version in startup banner
- src/smart_risk_manager.py: Use centralized versioning
Documentation:
- CLAUDE.md: Full versioning guidelines (SemVer, workflows, examples)
- CHANGELOG.md: Initial release documentation with feature tracking
- VERSION: Base version 0.0.0
Benefits:
- Professional version management (industry standard)
- Automatic feature tracking and version updates
- Complete change history with Keep a Changelog format
- Clear upgrade paths (MAJOR.MINOR.PATCH)
Version: v0.6.0 (Kalman + Fuzzy + Kelly + Predictive)
Exit Strategy: v6.3 Predictive Intelligence
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When regime detection fails silently on first iteration, df lacks
regime/regime_confidence columns. XGBoost then gets 74 features
instead of 76 and throws feature_names mismatch error.
Fix: add default regime columns (regime=1, regime_confidence=1.0)
after regime detection block and in the fallback position-check path.
Also upgrade regime error logging from DEBUG to WARNING for visibility.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enhance PositionGuard in SmartRiskManager with real-time profit velocity
($/s) and acceleration ($/s²) tracking for smarter exit decisions.
Changes:
- Add 7 velocity/acceleration fields to PositionGuard dataclass
- Add _calculate_velocity_acceleration(), _update_stagnation(), get_velocity_summary()
- Add 4 new exit checks: [VEL-EXIT], [DECEL], [VEL-WARN], [STAGNANT]
- Enhance early cut with velocity trigger alternative (vel < -0.4)
- Stricter profit_growing: requires momentum > 0 AND velocity > 0
- Reduce position check interval 10s → 5s for more data points
- Add per-ticket [MOMENTUM] log every 30s in main loop
- Revert unused momentum_tracker integration from position_manager
- Add deprecation note to profit_momentum_tracker.py
All velocity checks respect the 15-minute grace period.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
V2 model stores AUC as xgb_train_score/xgb_test_score instead of V1's
train_auc/test_auc. Dashboard now shows correct AUC: 73.4%.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 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>
1. Activate SmartPositionManager (was dead code) - trailing SL, breakeven,
market close handler, drawdown-from-peak protection now wired into live loop
2. Add flash crash detection between candles - _position_check_only() now
checks for flash crashes every 5s instead of only on 15min candle close
3. Fix signal confirmation persistence - use direction-based key instead of
exact price (which changed every candle), persist to file to survive restarts
4. Cache ML/features between candles - stop recalculating 37 features + XGBoost
every 5 seconds when candle hasn't changed, reuse cached values
5. Add H1 multi-timeframe SMC bias filter - fetch H1 data, analyze BOS/CHoCH/OB,
block M15 signals that contradict H1 bias, boost confidence when aligned
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix 'dict' has no attribute 'spread' by using .get("spread", 0)
- Add 3-retry loop to close_position() with fresh price each attempt
- Match retry pattern from send_order() for consistency
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Major Issue #1: Confidence Calculation Calibration
- Added calculate_confidence() method with weighted scoring
- Base 40% + Structure 15% + BOS/CHoCH 12% + FVG 8% + OB 10% + Trend 10%
- Capped at 85% (never 100% certain)
Major Issue #2: Pullback Filter ATR-based
- Replaced hardcoded $2, $1.5 thresholds
- Now uses bounce_threshold = 0.15 * ATR
- consolidation_threshold = 0.10 * ATR
Major Issue #3: Smarter Time-based Exit
- Don't cut winners short if profit growing
- Check ML agreement before timeout
- Extend time to 8h if profit > $10 and growing
Major Issue #4: Slippage Validation
- Check actual vs expected price after execution
- Log warning if slippage > 0.15% of price
- Use actual price for position tracking
Major Issue #5: Partial Fill Handling
- Check if filled volume < requested volume
- Log warning with fill ratio
- Use actual volume for position tracking
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
main_live.py:
- Switch main loop from time-based (1s) to candle-based (M15)
- Add position-only checks between candles (every 10s)
- Fix memory leak in signal persistence dict (cleanup stale entries)
- Raise auto-retrain rollback AUC threshold from 0.52 to 0.60
src/ml_model.py:
- Add 50-bar gap between train/test split to prevent temporal leakage
src/smart_risk_manager.py:
- Remove dangerous "Smart Hold" behavior (holding losers waiting for golden time)
- Replace with proper early cut logic (loss >30% + negative momentum)
src/smc_polars.py:
- Fix lookahead bias in FVG detection (remove shift(-1), use confirmed bars only)
- Fix lookahead bias in Swing Points (use center=False rolling window)
- Fix lookahead bias in Order Blocks (validate with current bar, not future)
- Enforce minimum 1:2 Risk:Reward ratio on all signals
- Always use current_close as entry price (no stale FVG/OB zone prices)
- Add ATR sanity check with realistic XAUUSD default ($12)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 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>