fix: stage missing code review fixes (7 files)

Files were edited but not staged in earlier commits:
- adaptive_rhythm_manager.py: mt→mt5, pytz→timezone, get_volatility_level, shutdown()
- check_market_regime.py: ADX_THRESHOLD, Wilder EWM, try/finally, UTC timestamp, sys import
- check_system_status.py: remove duplicate cursor.execute
- drawdown_protection.py: float(inf), persist pause state, DB save_setting, Markdown fix
- performance_analysis.py: KeyError export fix, profit factor, drawdown positive, SQL filter
- performance_analysis_simple.py: fromisoformat, numeric bin sort, profit factor
- trading_dashboard.py: st.rerun(), session_state auto-refresh, pathlib DB path, errors=coerce

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 12:25:11 +02:00
co-authored by Claude Sonnet 4.6
parent 5f11d9693c
commit dd2611eaef
7 changed files with 207 additions and 176 deletions
+17 -7
View File
@@ -3,11 +3,10 @@ Adaptive Rhythm Manager - Extracted from Notebook
Manages adaptive trading intervals based on volatility and session
"""
import MetaTrader5 as mt
import MetaTrader5 as mt5
import pandas as pd
import pandas_ta as ta
import pytz
from datetime import datetime, time
from datetime import datetime, time, timezone
import logging
logger = logging.getLogger(__name__)
@@ -51,7 +50,7 @@ class AdaptiveRhythmManager:
def get_current_session(self):
"""Ermittelt die aktuelle Trading-Session"""
now_utc = datetime.now(pytz.UTC).time()
now_utc = datetime.now(timezone.utc).time()
# Overlap hat höchste Priorität
if self.sessions['overlap'][0] <= now_utc <= self.sessions['overlap'][1]:
@@ -73,13 +72,19 @@ class AdaptiveRhythmManager:
def get_market_data(self):
"""Hole Marktdaten für ATR-Analyse"""
try:
rates = mt.copy_rates_from_pos(self.symbol, mt.TIMEFRAME_H1, 0, 50)
rates = mt5.copy_rates_from_pos(self.symbol, mt5.TIMEFRAME_H1, 0, 50)
if rates is None:
return None
df = pd.DataFrame(rates)
# mt5 may return a structured numpy array or DataFrame depending on version
df = rates if isinstance(rates, pd.DataFrame) else pd.DataFrame(rates)
df['time'] = pd.to_datetime(df['time'], unit='s')
df.set_index('time', inplace=True)
if len(df) < 14:
logger.warning(f"Not enough data for ATR calculation: {len(df)} bars")
return None
df['atr'] = ta.atr(df['high'], df['low'], df['close'], length=14)
return df
except Exception as e:
@@ -127,6 +132,11 @@ class AdaptiveRhythmManager:
else: # asian
return self.intervals['medium'] if volatility == 'high' else self.intervals['slow']
def shutdown(self):
"""Trennt MT5-Verbindung sauber"""
mt5.shutdown()
logger.info("AdaptiveRhythmManager: MT5 disconnected")
def get_status_report(self):
"""Erstellt Status-Report"""
session = self.get_current_session()
@@ -141,7 +151,7 @@ class AdaptiveRhythmManager:
return f"""
╔════════════════════════════════════════════════════════╗
║ ADAPTIVE RHYTHM STATUS - {datetime.now().strftime('%H:%M:%S UTC')}
║ ADAPTIVE RHYTHM STATUS - {datetime.now(timezone.utc).strftime('%H:%M:%S UTC')}
╠════════════════════════════════════════════════════════╣
║ Aktuelles Intervall: {self.current_interval:>2} Minuten ║
║ Trading Session: {session.upper():<15}