Files
Place-Order-Trading-Bot/debug_bot_status.py
T
cbazzaandClaude Sonnet 4.5 f9f4737b19
Deploy to Windows VPS / deploy (push) Has been cancelled
docs: Add bot analysis and performance report for January 2026
Added comprehensive documentation:
- BOT_ANALYSIS_2026-01-10.md: Trading gap analysis (07-11 Jan)
- PERFORMANCE_REPORT_JAN_2026.md: Full performance metrics
- debug_bot_status.py: Debug script for bot status checks

Performance highlights:
- 74 trade signals over 5 days
- 92.90% average confidence
- 56.7% trades with ≥95% confidence
- News Filter successfully blocked NFP event

Analysis findings:
- Bot working correctly since 12.01
- Trading gap 08-11 Jan explained (NFP + weekend)
- Lot size increased to 0.10

Updated files:
- Notebook with latest trading state
- Performance JSON with new trades (12-13 Jan)

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-14 12:10:07 +01:00

147 lines
4.0 KiB
Python

#!/usr/bin/env python3
"""
Debug Script - Bot Status Check
Prüft warum Bot nicht tradet
"""
import MetaTrader5 as mt5
from datetime import datetime
import json
print("=" * 70)
print("🔍 BOT STATUS DEBUG")
print("=" * 70)
print()
# 1. MT5 Connection
print("1. MT5 VERBINDUNG")
print("-" * 70)
if mt5.initialize():
print("✅ MT5 initialisiert")
# Terminal Info
terminal_info = mt5.terminal_info()
if terminal_info:
print(f" Terminal: {terminal_info.name}")
print(f" Connected: {terminal_info.connected}")
print(f" Trade Allowed: {terminal_info.trade_allowed}")
# Account Info
account_info = mt5.account_info()
if account_info:
print(f" Account: {account_info.login}")
print(f" Balance: ${account_info.balance:.2f}")
print(f" Equity: ${account_info.equity:.2f}")
print(f" Trade Allowed: {account_info.trade_allowed}")
print(f" Trade Expert: {account_info.trade_expert}")
# Symbol Info
symbol_info = mt5.symbol_info("XAUUSD")
if symbol_info:
print(f" XAUUSD visible: {symbol_info.visible}")
print(f" XAUUSD trade_mode: {symbol_info.trade_mode}")
print(f" Current Bid: {symbol_info.bid}")
print(f" Current Ask: {symbol_info.ask}")
# Offene Positionen
positions = mt5.positions_get(symbol="XAUUSD")
if positions:
print(f" Offene Positionen: {len(positions)}")
for pos in positions:
print(f" - Ticket {pos.ticket}: {pos.type} {pos.volume} lots @ {pos.price_open}")
else:
print(f" Offene Positionen: 0")
else:
print("❌ MT5 Initialisierung fehlgeschlagen!")
print(f" Error: {mt5.last_error()}")
print()
# 2. Letzte Orders
print("2. LETZTE ORDERS (History)")
print("-" * 70)
from datetime import timedelta
now = datetime.now()
from_date = now - timedelta(days=4)
mt5.initialize()
deals = mt5.history_deals_get(from_date, now)
if deals:
print(f"Total Deals (letzte 4 Tage): {len(deals)}")
print()
print("Letzte 5 Deals:")
for deal in list(deals)[-5:]:
deal_time = datetime.fromtimestamp(deal.time)
print(f" {deal_time}: {deal.symbol} {deal.type} {deal.volume} lots @ {deal.price}")
else:
print("❌ Keine Deals in den letzten 4 Tagen!")
print()
# 3. Market Status
print("3. MARKET STATUS")
print("-" * 70)
symbol_info = mt5.symbol_info("XAUUSD")
if symbol_info:
print(f"Market Open: {symbol_info.session_deals > 0}")
print(f"Trading Session: {symbol_info.trade_mode}")
# Check if weekend
now = datetime.now()
weekday = now.weekday()
if weekday >= 5: # Saturday = 5, Sunday = 6
print(f"⚠️ WOCHENENDE (Tag {weekday}) - Markt geschlossen!")
else:
print(f"✅ Wochentag ({weekday}) - Markt sollte offen sein")
# Check trading hours
hour = now.hour
print(f"Aktuelle Zeit: {now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f"UTC Hour: {hour}")
print()
# 4. Last Trade from JSON
print("4. LETZTER TRADE (aus JSON)")
print("-" * 70)
try:
with open('trade_performance_v16_XAUUSD_202601.json', 'r') as f:
trades = json.load(f)
if trades:
last_trade = trades[-1]
print(f"Zeitstempel: {last_trade['timestamp']}")
print(f"Confidence: {last_trade['confidence']}%")
print(f"Session: {last_trade['session']}")
last_time = datetime.fromisoformat(last_trade['timestamp'])
delta = now - last_time
hours = delta.total_seconds() / 3600
print(f"Vor {delta.days} Tagen, {int(hours % 24)} Stunden")
except Exception as e:
print(f"❌ Error reading JSON: {e}")
print()
# 5. News Filter Status
print("5. NEWS FILTER STATUS")
print("-" * 70)
try:
from news_filter_simple import is_news_upcoming
if is_news_upcoming(minutes_ahead=30, minutes_after=30):
print("❌ NEWS FILTER AKTIV - Trading blockiert!")
else:
print("✅ NEWS FILTER INAKTIV - Trading erlaubt")
except Exception as e:
print(f"⚠️ News Filter Error: {e}")
print()
print("=" * 70)
print("✅ DEBUG COMPLETE")
print("=" * 70)
mt5.shutdown()