Implement session-specific confidence thresholds (NY Fine-Tuning)

FEATURE: Session-Specific Confidence Thresholds
- Asian: >=95% Confidence (unchanged, 97.8% WR)
- NY: >=97% Confidence (NEW, improves WR from 43.3% to 56.5%!)
- London/Overlap: Blocked (as before)

EXPECTED IMPACT:
- Eliminates 7 poor NY trades (all <97% confidence)
- NY Win-Rate: 43.3% → 56.5% (+13.2 pp)
- NY Profit: $1,418 → $1,655 (+$237)
- Total Profit: $8,306 → $8,598 (+$292)
- Overall Win-Rate: 67.8% → ~71%

IMPLEMENTATION:
1. session_filter_patch.py
   - Added session_confidence_thresholds config
   - New function: get_session_confidence_threshold()
   - New function: is_confidence_sufficient()

2. session_confidence_filter.py (NEW)
   - Wrapper for execute_trade_v2_adaptive
   - Session-specific confidence checks
   - Test suite (6/6 tests passed ✅)

3. analyze_ny_session.py (NEW)
   - Detailed NY session analysis
   - Simulations for different thresholds
   - Data shows 97-98% trades had 100% WR

TESTING:
All 6 test cases passed:
- Asian 96%: ALLOWED ✅
- Asian 94%: BLOCKED ✅
- NY 98%: ALLOWED ✅
- NY 96%: BLOCKED ✅
- London 99%: BLOCKED ✅
- Overlap 99%: BLOCKED ✅

NEXT STEPS:
1. Integrate wrapper into notebook
2. Restart kernel
3. Monitor for 1 week
4. Review performance improvement

FILES:
- session_filter_patch.py: Updated config + new functions
- session_confidence_filter.py: Wrapper implementation
- analyze_ny_session.py: Analysis tool
- NY_SESSION_FINETUNING.md: Complete documentation
This commit is contained in:
cbazza committed 2025-12-26 17:46:58 +01:00
1 parent 26d1802bb1
commit ce197c06f4
4 files changed
+735 -32

No files matched your search

+61 -32
View File
@@ -20,14 +20,22 @@ PERFORMANCE-IMPACT:
SESSION_WHITELIST_CONFIG = {
# Welche Sessions erlauben?
'enabled_sessions': {
'asian': True, # ❌ DEAKTIVIERT: +$202, aber nur 30.2% Win-Rate
'london': False, # ❌ DEAKTIVIERT: +$79, aber nur 30.8% Win-Rate
'overlap': False, # ❌ DEAKTIVIERT: -$208 kumuliert (2 Wochen), 27.3% Win-Rate
'ny': True, # ✅ NUR NY AKTIV: +$660, 47.6% Win-Rate (BESTE!)
'asian': True, # ✅ BESTE SESSION: 97.8% Win-Rate, $151/Trade
'london': False, # ❌ BLOCKIERT: 12.5% Win-Rate, -$10/Trade
'overlap': False, # ❌ BLOCKIERT: 14.3% Win-Rate, -$7/Trade
'ny': True, # ✅ AKTIV: 43.3% Win-Rate, aber profitabel ($48/Trade)
},
# Session-spezifische Confidence Thresholds (NEU 26.12.2025)
'session_confidence_thresholds': {
'asian': 95, # Asian: >=95% OK (läuft perfekt mit 97.8% WR)
'ny': 97, # NY: >=97% benötigt (verbessert WR von 43% auf 56.5%!)
'london': 95, # London: blockiert, Threshold irrelevant
'overlap': 95, # Overlap: blockiert, Threshold irrelevant
},
# Trading Parameter
'base_confidence': 70, # 🎯 CONFIDENCE THRESHOLD (60=relaxed, 70=balanced, 75=konservativ, 80=sehr strikt)
'base_confidence': 95, # 🎯 GLOBAL THRESHOLD (Minimum für alle Sessions)
'atr_mult': 1.5, # ATR Multiplikator für SL/TP
'max_risk_per_trade': 0.02, # Max Risk pro Trade (2%) - Erhöht am 20.12.2025 für Adaptive Sizing
'min_atr': 0.0008, # Minimum ATR für Risk Filter
@@ -36,21 +44,53 @@ SESSION_WHITELIST_CONFIG = {
'risk_filter': True, # ATR-basierter Risk Filter
'use_pullback_entry': False, # Pullback Entry Strategie
# Alternativ: Aggressive Mode (nur NY)
'aggressive_mode': False, # ⚠️ Nicht nötig - already configured via enabled_sessions
# Alternativ: Conservative Mode (NY + Overlap + London)
'conservative_mode': False, # ⚠️ Nicht aktiv
# Debug-Modus
'debug': True,
}
# ==========================================
# SESSION FILTER FUNCTION
# SESSION FILTER FUNCTIONS
# ==========================================
def get_session_confidence_threshold(session_name, config=SESSION_WHITELIST_CONFIG):
"""
Holt den session-spezifischen Confidence Threshold
Args:
session_name: 'asian', 'london', 'overlap', 'ny'
config: Configuration Dictionary
Returns:
int: Minimum confidence threshold für diese Session
"""
thresholds = config.get('session_confidence_thresholds', {})
return thresholds.get(session_name, config.get('base_confidence', 95))
def is_confidence_sufficient(session_name, confidence, config=SESSION_WHITELIST_CONFIG):
"""
Prüft ob Confidence für diese Session ausreichend ist
Args:
session_name: 'asian', 'london', 'overlap', 'ny'
confidence: Signal Confidence (0-100)
config: Configuration Dictionary
Returns:
(sufficient: bool, reason: str)
"""
required = get_session_confidence_threshold(session_name, config)
sufficient = confidence >= required
if not sufficient:
reason = f"{session_name.upper()} requires >={required}% confidence (got {confidence:.1f}%)"
else:
reason = f"Confidence {confidence:.1f}% >= {required}% for {session_name.upper()}"
return sufficient, reason
def is_session_allowed(session_name, config=SESSION_WHITELIST_CONFIG):
"""
Prüft ob Trading in aktueller Session erlaubt ist
@@ -63,36 +103,25 @@ def is_session_allowed(session_name, config=SESSION_WHITELIST_CONFIG):
(allowed: bool, reason: str)
"""
# Aggressive Mode: Nur NY
if config['aggressive_mode']:
allowed = session_name == 'ny'
reason = f"Aggressive Mode: Only NY session" if not allowed else "NY session - best performance"
return allowed, reason
# Conservative Mode: Alle außer Asian
if config['conservative_mode']:
allowed = session_name != 'asian'
reason = f"Conservative Mode: Asian disabled" if not allowed else f"{session_name.upper()} session allowed"
return allowed, reason
# Standard: Whitelist-basiert
allowed = config['enabled_sessions'].get(session_name, False)
if not allowed:
reasons = {
'asian': "Session blocked: Asian has -$199 loss, 25.6% win-rate",
'london': "Session blocked: London is break-even, 29.6% win-rate",
'overlap': "Session blocked: Not in whitelist",
'ny': "Session blocked: Not in whitelist",
'asian': "Asian: 97.8% WR but currently disabled",
'london': "London blocked: 12.5% win-rate, -$10/trade",
'overlap': "Overlap blocked: 14.3% win-rate, -$7/trade",
'ny': "NY: 43.3% WR but currently disabled",
}
reason = reasons.get(session_name, f"Session {session_name} not in whitelist")
else:
performance = {
'ny': "+$372 profit, 50.0% win-rate (BEST!)",
'overlap': "+$209 profit, 32.1% win-rate (GOOD)",
'london': "+$7 profit, 29.6% win-rate (Break-even)",
'asian': "Asian allowed: 97.8% WR, $151/trade (EXCELLENT!)",
'ny': "NY allowed: 43.3% WR, $48/trade (needs >=97% conf)",
'london': "London allowed: 12.5% WR (low)",
'overlap': "Overlap allowed: 14.3% WR (low)",
}
reason = f"{session_name.upper()} allowed: {performance.get(session_name, 'In whitelist')}"
reason = f"{performance.get(session_name, 'In whitelist')}"
return allowed, reason