fix: equity_curve_trading, infrastructure_patch + news filter cleanup
equity_curve_trading.py: - mt→mt5 alias in _get_current_equity() - safe-fail: return False (block trade) when equity unavailable - UTC timestamps via timezone.utc in update_equity() - add_initial_equity(): unique timestamps (staggered by minute) instead of identical infrastructure_patch.py: - Add logging module, replace all print() with logger calls - Fix guard: self.db/self.telegram instead of enable_database/enable_telegram - Fix UTC bug in extract_trade_data_from_mt5() (fromtimestamp with tz=utc) - Remove direct self.db.cursor.execute() in log_trade_exit() — use get_open_trades() - Read risk_pct from SESSION_WHITELIST_CONFIG instead of hardcoding 0.01 news_filter.py / news_filter_v2.py: - Remove both inactive variants (ForexFactory scraper + Finnhub API) - news_filter_simple.py + news_filter_integration.py remain as active implementation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ VERWENDUNG:
|
||||
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from typing import List, Dict, Optional, Tuple
|
||||
import logging
|
||||
|
||||
@@ -111,7 +111,8 @@ class EquityCurveManager:
|
||||
# Aktuelle Equity holen
|
||||
current_equity = self._get_current_equity(mt5_account_info)
|
||||
if current_equity is None:
|
||||
return True, "Could not get equity, allowing trade", 1.0
|
||||
logger.error("Could not get equity from MT5 — blocking trade as safe default")
|
||||
return False, "Equity unavailable — trade blocked for safety", 0.0
|
||||
|
||||
# MA berechnen
|
||||
ma_equity = self._calculate_ma()
|
||||
@@ -157,7 +158,7 @@ class EquityCurveManager:
|
||||
return
|
||||
|
||||
entry = {
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
"equity": current_equity,
|
||||
"trade_count": len(self.equity_history) + 1
|
||||
}
|
||||
@@ -255,8 +256,8 @@ class EquityCurveManager:
|
||||
return mt5_account_info.equity
|
||||
|
||||
try:
|
||||
import MetaTrader5 as mt
|
||||
account = mt.account_info()
|
||||
import MetaTrader5 as mt5
|
||||
account = mt5.account_info()
|
||||
if account:
|
||||
return account.equity
|
||||
except Exception as e:
|
||||
@@ -306,9 +307,11 @@ class EquityCurveManager:
|
||||
|
||||
Nützlich wenn du mit bestehendem Konto startest
|
||||
"""
|
||||
base_time = datetime.now(timezone.utc)
|
||||
for i in range(self.min_trades):
|
||||
ts = (base_time - timedelta(minutes=self.min_trades - i)).isoformat()
|
||||
self.equity_history.append({
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"timestamp": ts,
|
||||
"equity": equity,
|
||||
"trade_count": i + 1,
|
||||
"note": "Initial warmup entry"
|
||||
|
||||
Reference in New Issue
Block a user