From 4ac27cc7b42dd9ddb3440b8a0a5bc6f1cac472b4 Mon Sep 17 00:00:00 2001 From: cbazza Date: Fri, 30 Jan 2026 17:18:29 +0100 Subject: [PATCH] feat: Add Loss Protection Manager with multi-layer safety system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Daily loss limit (2% / $500 max) - Consecutive loss breaker (3 losses β†’ 2h cooldown) - Max drawdown circuit breaker (10% threshold) - News filter with 30min buffer for high-impact events - Integrated as SCHRITT 0.5 in enhanced_trading_check_wrapper - Combined lot multiplier with Equity Curve and Reversal Detector Co-Authored-By: Claude Opus 4.5 --- ...Bot_V1.6_Adaptive_Complete_CORRECTED.ipynb | 2705 +++++++++++++---- loss_protection_manager.py | 654 ++++ 2 files changed, 2794 insertions(+), 565 deletions(-) create mode 100644 loss_protection_manager.py diff --git a/TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb b/TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb index 00373dc..2be018d 100644 --- a/TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb +++ b/TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb @@ -45,9 +45,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 54, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“¦ Installing python-telegram-bot...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:09:00,147 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:10:00 CET)\" (scheduled at 2026-01-30 17:09:00+01:00)\n", + "2026-01-30 17:09:00,160 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:10:00 CET)\" executed successfully\n", + "2026-01-30 17:09:09,696 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:09:19,735 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "βœ… python-telegram-bot installed!\n", + "βœ… Version: 22.6\n", + "\n", + "🎯 Now restart kernel and run Cell 17 again!\n" + ] + } + ], "source": [ "# ==========================================\n", "# INSTALL TELEGRAM DEPENDENCIES (Run FIRST!)\n", @@ -73,9 +102,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 55, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… All imports successful - V1.6 Adaptive Complete (CORRECTED)\n" + ] + } + ], "source": [ "# Standard Imports\n", "import pandas as pd\n", @@ -106,9 +143,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 56, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Infrastructure modules loaded\n" + ] + } + ], "source": [ "# ==========================================\n", "# INFRASTRUCTURE IMPORTS (V1.8)\n", @@ -135,9 +180,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… TRADING CONFIGURATION LOADED\n", + "\n", + "πŸ“Š Lot Sizing: 0.01 - 0.2 lots\n", + "⚠️ Max Risk: 2.0% per trade\n", + "🎯 Confidence Threshold: 70%\n", + "πŸ›‘οΈ News Filter: ENABLED\n", + "🌍 Primary Symbol: XAUUSD\n" + ] + } + ], "source": [ "# ============================================================================\n", "# CENTRALIZED TRADING CONFIGURATION\n", @@ -247,9 +306,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Adaptive Rhythm Manager defined\n" + ] + } + ], "source": [ "class AdaptiveRhythmManager:\n", " \"\"\"\n", @@ -405,9 +472,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 59, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Login successful: True\n", + "Symbol: XAUUSD\n", + "Strategy: TradingBot_V1.6\n", + "Max Positions: 1\n", + "Version: V1.6 COMPLETE - Adaptive + Full Features! πŸš€πŸ›‘οΈβš‘\n", + "\n", + "\n", + "╔════════════════════════════════════════════════════════╗\n", + "β•‘ ADAPTIVE RHYTHM STATUS - 17:09:28 UTC β•‘\n", + "╠════════════════════════════════════════════════════════╣\n", + "β•‘ Aktuelles Intervall: 5 Minuten β•‘\n", + "β•‘ Trading Session: NY β•‘\n", + "β•‘ VolatilitΓ€tslevel: HIGH β•‘\n", + "β•‘ ATR (H1): 88.26 β•‘\n", + "╠════════════════════════════════════════════════════════╣\n", + "β•‘ INTERVALL-SCHEMA: β•‘\n", + "β•‘ β€’ Overlap (13-16 UTC): 5-15 Min (aktivste Phase) β•‘\n", + "β•‘ β€’ London/NY: 5-30 Min (volatilitΓ€tsabh.) β•‘\n", + "β•‘ β€’ Asian Session: 15-30 Min (ruhigere Phase) β•‘\n", + "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•\n", + "\n" + ] + } + ], "source": [ "# MT5 Login\n", "mt.initialize()\n", @@ -434,9 +529,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ”§ Initializing Infrastructure...\n", + "βœ… Database initialized: trading_bot.db\n", + "βœ… Telegram Bot connected: @Xausd_digger_bot\n", + "βœ… Telegram notifications enabled\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:09:29,767 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Infrastructure ready!\n", + " Database: βœ…\n", + " Telegram: βœ…\n" + ] + } + ], "source": [ "# ==========================================\n", "# INITIALIZE INFRASTRUCTURE (V1.8)\n", @@ -470,9 +592,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:09:29,919 - INFO - 🎯 Advanced Position Manager initialized\n", + "2026-01-30 17:09:29,922 - INFO - Adaptive Sizing: βœ…\n", + "2026-01-30 17:09:29,923 - INFO - Trailing Stop: βœ…\n", + "2026-01-30 17:09:29,924 - INFO - Partial TP: βœ…\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🎯 Initializing Advanced Position Management...\n", + "βœ… Advanced Position Management activated!\n", + " πŸ“Š Adaptive Position Sizing: ACTIVE\n", + " β€’ High Confidence (β‰₯80%): 1.5x risk\n", + " β€’ Medium Confidence (β‰₯70%): 1.0x risk\n", + " β€’ Low Confidence (<70%): 0.5x risk\n", + "\n", + " πŸ“ˆ Trailing Stop-Loss: ACTIVE\n", + " β€’ Break-Even at 50% progress to TP\n", + " β€’ Lock 50% profit at 75% progress\n", + "\n", + " 🎯 Partial Take Profit: ACTIVE\n", + " β€’ TP1 at 1.5R (close 50%)\n", + " β€’ TP2 at 2.5R (let 50% run)\n" + ] + } + ], "source": [ "# ==========================================\n", "# ADVANCED POSITION MANAGEMENT SETUP\n", @@ -508,9 +661,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ”§ Initializing Position Monitor...\n", + "βœ… Position Monitor ready!\n", + " Will check for closed positions every minute\n", + " Closed trades will be automatically logged with:\n", + " β€’ Exit price & time\n", + " β€’ Profit/Loss calculation\n", + " β€’ Exit reason (TP/SL/Manual)\n", + " β€’ Telegram notification\n" + ] + } + ], "source": [ "# ==========================================\n", "# POSITION MONITOR SETUP (V1.8)\n", @@ -541,9 +709,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 63, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Position Control functions defined (COMPLETE with close function!)\n" + ] + } + ], "source": [ "def check_existing_positions(symbol=\"XAUUSD\", strategy_name=\"TradingBot_V1.6\"):\n", " \"\"\"\n", @@ -665,9 +841,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 64, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Helper functions defined (with robust MT5 retry logic)\n" + ] + } + ], "source": [ "import time\n", "\n", @@ -781,9 +965,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 65, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Market analysis functions defined (with RELAXED thresholds)\n" + ] + } + ], "source": [ "def detect_market_regime(df, lookback=50):\n", " \"\"\"Market Regime Detection\"\"\"\n", @@ -888,9 +1080,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 66, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Enhanced trend wrapper ready (retries handled in get_rates)\n" + ] + } + ], "source": [ "# ==========================================\n", "# SIMPLIFIED: get_rates now handles retries\n", @@ -914,9 +1114,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 67, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… V1.6 Adaptive Complete Top-Down Analysis defined\n" + ] + } + ], "source": [ "def extended_top_down_v2_adaptive(symbol=\"XAUUSD\", lookback=150):\n", " \"\"\"\n", @@ -1098,9 +1306,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 68, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Entry timing functions defined (DISABLED in Relaxed mode)\n" + ] + } + ], "source": [ "def check_pullback_entry(symbol, signal_info, timeframe=\"M5\"):\n", " \"\"\"\n", @@ -1150,7 +1366,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 69, "metadata": {}, "outputs": [], "source": [ @@ -1203,9 +1419,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 70, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.01" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#mt.symbol_info(symbol).volume_min\n", "mt.symbol_info(symbol).volume_step" @@ -1213,9 +1440,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 71, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… V1.6 Adaptive Complete Execute Trade defined\n" + ] + } + ], "source": [ "def execute_trade_v2_adaptive(\n", " symbol=None,\n", @@ -1477,9 +1712,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 72, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… SESSION-SPECIFIC CONFIDENCE FILTER AKTIVIERT\n", + "------------------------------------------------------------\n", + "Thresholds:\n", + " Asian: >= 95% Confidence (97.8% WR)\n", + " NY: >= 97% Confidence (verbessert von 43% auf 56% WR)\n", + " London: Blockiert\n", + " Overlap: Blockiert\n", + "\n", + "Erwartete Verbesserung:\n", + " - NY Win-Rate: 43.3% β†’ 56.5%\n", + " - Profit: +$237/Monat in NY Session\n", + " - Gesamt: +$292/Monat\n", + "------------------------------------------------------------\n" + ] + } + ], "source": [ "# ==========================================\n", "# SESSION-SPECIFIC CONFIDENCE FILTER (26.12.2025)\n", @@ -1514,9 +1769,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 73, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“¦ Installing python-telegram-bot...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:09:39,797 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:09:40,929 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:10:40 CET)\" (scheduled at 2026-01-30 17:09:40.796150+01:00)\n", + "2026-01-30 17:09:40,931 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:10:40 CET)\" executed successfully\n", + "2026-01-30 17:09:40,928 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:10:40 CET)\" (scheduled at 2026-01-30 17:09:40.794207+01:00)\n", + "2026-01-30 17:09:40,936 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:10:40 CET)\" executed successfully\n", + "2026-01-30 17:09:49,836 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… python-telegram-bot installed successfully!\n", + "βœ… telegram module version: 22.6\n" + ] + } + ], "source": [ "# ==========================================\n", "# INSTALL TELEGRAM BOT DEPENDENCIES\n", @@ -1580,9 +1863,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 74, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸš€ Starting Telegram Bot Commander...\n", + "βœ… Telegram Bot Commander initialized\n", + "πŸ“± Bot Token: 7783303065:AAHVVvwWG...\n", + "πŸ‘€ Chat ID: 8039713369\n", + "βœ… Telegram Bot running in background\n", + "βœ… Telegram Bot is running in background!\n", + "πŸ“± Available Commands:\n", + " /status - Bot status & positions\n", + " /pause - Pause trading\n", + " /resume - Resume trading\n", + " /close - Close all positions (requires confirm)\n", + " /balance - Account balance\n", + " /stats - Performance stats\n", + " /help - Show help\n" + ] + } + ], "source": [ "# ==========================================\n", "# TELEGRAM BOT COMMANDS - Background Service\n", @@ -1648,9 +1952,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 75, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… NEWS FILTER ACTIVATED\n", + "------------------------------------------------------------\n", + "Protection: Trading blocked 30min before/after HIGH-IMPACT news\n", + "Events monitored:\n", + " β€’ NFP (Non-Farm Payrolls)\n", + " β€’ CPI (Consumer Price Index)\n", + " β€’ FOMC (Fed Interest Rate Decision)\n", + " β€’ Retail Sales, PMI, GDP\n", + " β€’ Other high-impact USD/EUR/GBP events\n", + "------------------------------------------------------------\n", + "\n", + "πŸ“ To add events: Edit news_events_manual.json\n", + "πŸ’‘ Recommended: Weekly check ForexFactory calendar\n" + ] + } + ], "source": [ "# ==========================================\n", "# NEWS FILTER INTEGRATION\n", @@ -1684,9 +2008,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 76, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… execute_trade_v2_adaptive wrapped with Telegram control\n", + " Trading can now be paused/resumed via /pause and /resume\n" + ] + } + ], "source": [ "# ==========================================\n", "# INTEGRATION: Bot Controller mit execute_trade\n", @@ -1766,7 +2099,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 77, "metadata": {}, "outputs": [], "source": [ @@ -1845,9 +2178,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 78, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Multi-Timeframe Ranging Filter aktiviert!\n", + " PrΓΌft: H1, H4, D1\n", + " Gewichtung: D1 (3x) > H4 (2x) > H1 (1x)\n", + " Threshold: ADX > 25\n", + "\n", + "πŸ“Š Entscheidungslogik:\n", + " 1. D1 ADX > 30 β†’ ERLAUBT (starker Trend)\n", + " 2. H4+D1 beide > 25 β†’ ERLAUBT (bestΓ€tigter Trend)\n", + " 3. Weighted ADX > 25 β†’ ERLAUBT (Gesamtbild)\n", + " 4. Sonst β†’ BLOCKIERT (Ranging)\n" + ] + } + ], "source": [ "# ==========================================\n", "# 🎯 MULTI-TIMEFRAME RANGING FILTER (20.12.2025)\n", @@ -1879,9 +2229,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 79, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ§ͺ TESTING MULTI-TIMEFRAME REGIME FILTER\n", + "======================================================================\n", + "\n", + "\n", + "πŸ“Š MULTI-TIMEFRAME REGIME CHECK\n", + "============================================================\n", + " H1: ADX 52.4 (weight 1.0x) βœ… TREND\n", + " H4: ADX 38.6 (weight 2.0x) βœ… TREND\n", + " D1: ADX 47.5 (weight 3.0x) βœ… TREND\n", + "\n", + " Weighted ADX: 45.3\n", + " Threshold: 25\n", + "\n", + " βœ… ALLOWED: TRENDING\n", + " Reason: D1 stark trending (ADX 47.5 > 30) β†’ Trend dominiert\n", + "============================================================\n", + "\n", + "πŸ“‹ ERGEBNIS:\n", + " Trading Allowed: True\n", + " Regime: trending\n", + " Weighted ADX: 45.3\n", + "\n", + "βœ… FILTER ERLAUBT TRADES!\n", + " β†’ Bot wird bei nΓ€chstem Scheduler-Run traden (wenn andere Bedingungen passen)\n" + ] + } + ], "source": [ "# ==========================================\n", "# πŸ§ͺ TEST: Multi-Timeframe Regime Filter\n", @@ -1914,9 +2295,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 80, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "⚠️ check_open_positions not found - skipping Position Monitor fix\n" + ] + } + ], "source": [ "# ==========================================\n", "# πŸ”₯ FIX #2: POSITION MONITOR DB LOGGING (09.12.2025)\n", @@ -1987,9 +2376,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 81, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Performance Monitoring functions defined (with adaptive features)\n" + ] + } + ], "source": [ "def log_trade_performance_adaptive(signal_info, order_result):\n", " \"\"\"\n", @@ -2110,9 +2507,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 82, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ”§ Force resuming trading after Ranging Filter deployment..." + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:09:57,180 - INFO - βœ… Trading resumed after: None\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "βœ… Status after resume:\n", + " Can Trade: True\n", + " Reason: All clear!\n", + "\n", + "πŸ›‘οΈ Drawdown Protection Status:\n", + " Consecutive Losses: 0\n", + " Trading Allowed: True\n" + ] + } + ], "source": [ "# ==========================================\n", "# FORCE RESUME TRADING (V2.2 FIX)\n", @@ -2151,9 +2578,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 83, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ”§ Setting up Trading Check...\n", + "βœ… Session Filter aktiviert!\n", + " Deaktivierte Sessions:\n", + " β€’ ASIAN : βœ… AKTIV\n", + " β€’ LONDON : ❌ DEAKTIVIERT\n", + " β€’ OVERLAP : βœ… AKTIV\n", + " β€’ NY : βœ… AKTIV\n", + "\n", + "πŸ›‘οΈ Drawdown Protection aktiviert!\n", + " β€’ Daily Loss Limit: $100\n", + " β€’ Weekly Loss Limit: $300\n", + " β€’ Monthly Loss Limit: $800\n", + " β€’ Max Consecutive Losses: 5\n", + " β€’ Cooldown: 24h\n", + "\n", + "βœ… Trading Check ist jetzt vollstΓ€ndig geschΓΌtzt!\n", + " πŸ“Š Session Filter: Aktiv\n", + " πŸ›‘οΈ Drawdown Protection: Aktiv\n" + ] + } + ], "source": [ "# ==========================================\n", "# TRADING CHECK: SESSION FILTER + DRAWDOWN PROTECTION\n", @@ -2205,7 +2657,80 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:09:59,058 - INFO - βœ… Trading resumed after: None\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Command handlers registered\n", + "πŸš€ Starting Telegram Bot...\n", + "πŸ“± Send /help to see available commands\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:09:59,864 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:10:00,011 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:11:00 CET)\" (scheduled at 2026-01-30 17:10:00+01:00)\n", + "2026-01-30 17:10:00,055 - INFO - \n", + "⏰ 2026-01-30 17:10:00 - ADAPTIVE Check\n", + "2026-01-30 17:10:00,061 - INFO - βœ… Session: NY - NY allowed: 43.3% WR, $48/trade (needs >=97% conf)\n", + "2026-01-30 17:10:00,064 - INFO - πŸ“Š Confidence Threshold: 95%\n", + "2026-01-30 17:10:00,066 - INFO - ⏱️ Intervall: 5 min\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ“Š MULTI-TIMEFRAME REGIME CHECK\n", + "============================================================\n", + " H1: ADX 52.4 (weight 1.0x) βœ… TREND\n", + " H4: ADX 38.6 (weight 2.0x) βœ… TREND\n", + " D1: ADX 47.5 (weight 3.0x) βœ… TREND\n", + "\n", + " Weighted ADX: 45.3\n", + " Threshold: 25\n", + "\n", + " βœ… ALLOWED: TRENDING\n", + " Reason: D1 stark trending (ADX 47.5 > 30) β†’ Trend dominiert\n", + "============================================================\n", + "\n", + "βœ… REGIME CHECK PASSED: TRENDING\n", + " Reason: D1 stark trending (ADX 47.5 > 30) β†’ Trend dominiert\n", + "\n", + "πŸ” POSITION CHECK fΓΌr XAUUSD (V1.6 Adaptive Complete)\n", + "βœ… Position-Check OK: 0/1\n", + "πŸ” Analyzing XAUUSD with V1.6 ADAPTIVE COMPLETE parameters...\n", + "βœ… Trading force-resumed (Ranging Filter deployed)\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:00,261 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/sendMessage \"HTTP/1.1 200 OK\"\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:00,297 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getMe \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:10:00,302 - INFO - Application started\n", + "2026-01-30 17:10:00,349 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/deleteWebhook \"HTTP/1.1 200 OK\"\n" + ] + } + ], "source": [ "# Force resume after restart (V2.2 fix)\n", "drawdown_protection._resume_trading()\n", @@ -2214,9 +2739,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 85, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:00,439 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:11:00 CET)\" executed successfully\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ“Š V1.6 ADAPTIVE COMPLETE Trend-Analyse fΓΌr XAUUSD\n", + "⚑ Adaptive Interval: 5 min | Session: NY\n", + "🎯 Market Regime: RANGING (Strength: 22%)\n", + "🎚️ Adaptive Threshold: 70% (RELAXED)\n", + "\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "| TF | Trend | Strength | ATR | Slope | Price |\n", + "|------+-----------+------------+----------+-----------+---------|\n", + "| D1 | uptrend | 438.22 | 166.05 | 10.915 | 5032.89 |\n", + "| H4 | uptrend | 331.97 | 127.543 | 6.35116 | 5032.95 |\n", + "| H1 | uptrend | 265.08 | 87.4591 | 3.4775 | 5033.04 |\n", + "| M30 | uptrend | 52.07 | 65.4288 | 0.511049 | 5033.04 |\n", + "| M15 | downtrend | 568.51 | 46.2663 | -3.94543 | 5033.36 |\n", + "| M5 | downtrend | 336.99 | 25.0953 | -1.26851 | 5033.36 |\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "\n", + "➑️ Standard-Trend: uptrend (Strength: 395.72)\n", + "➑️ Fast-Trend: downtrend (Required: 2/4)\n", + "➑️ Top-Down-Trend: sideways\n", + "➑️ Confidence: 0.0% (Threshold: 70%)\n", + "➑️ Risk-Adjusted Strength: 0.0 (Min: 80)\n", + "➑️ Signal Quality: NONE\n", + "\n", + "πŸš€ V1.6 Adaptive Complete: Full Features + Adaptive Rhythm\n", + "\n", + "⏸️ TRADE SKIPPED: Confidence 0.0% < threshold 70%\n", + "βœ… Bot is running\n" + ] + } + ], "source": [ "# def adaptive_trading_check():\n", "# \"\"\"\n", @@ -2260,9 +2827,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 86, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βš™οΈ V1.6 Adaptive Complete Configuration:\n", + "\n", + "πŸ›‘οΈ Position Control:\n", + " Max Positions: 1\n", + " Strategy: TradingBot_V1.6\n", + "\n", + "πŸš€ Relaxed Parameters:\n", + " Base Confidence: 60%\n", + " Min ATR: 0.0008\n", + " Pullback Entry: False\n", + "\n", + "⚑ Adaptive Features:\n", + " Dynamic Intervals: 5/15/30 min\n", + " Session-aware: Yes\n", + " Volatility-based: Yes\n", + "\n", + "βœ… Configuration complete!\n" + ] + } + ], "source": [ "# ============================================================================\n", "# NOTE: This config is DEPRECATED - use TRADING_CONFIG in Cell 6 instead\n", @@ -2310,9 +2901,59 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 87, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Status monitoring function defined (COMPLETE with all features)\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:00,536 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:00,540 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n" + ] + } + ], "source": [ "# βœ… KORRIGIERT: Umfassendes Status Monitoring (fehlte in V1.6)\n", "def check_adaptive_bot_status():\n", @@ -2396,9 +3037,57 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 88, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:00,584 - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts\n", + "2026-01-30 17:10:00,586 - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts\n", + "2026-01-30 17:10:00,588 - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts\n", + "2026-01-30 17:10:00,590 - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts\n", + "2026-01-30 17:10:00,592 - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts\n", + "2026-01-30 17:10:00,594 - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts\n", + "2026-01-30 17:10:00,597 - INFO - Added job \"create_protected_trading_check..protected_check\" to job store \"default\"\n", + "2026-01-30 17:10:00,598 - INFO - Added job \"print_status_report\" to job store \"default\"\n", + "2026-01-30 17:10:00,600 - INFO - Added job \"TradingInfrastructure.send_daily_report\" to job store \"default\"\n", + "2026-01-30 17:10:00,601 - INFO - Added job \"TradingInfrastructure.send_weekly_report\" to job store \"default\"\n", + "2026-01-30 17:10:00,602 - INFO - Added job \"PositionMonitor.check_open_positions\" to job store \"default\"\n", + "2026-01-30 17:10:00,603 - INFO - Added job \"\" to job store \"default\"\n", + "2026-01-30 17:10:00,604 - INFO - Scheduler started\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Scheduled reports added:\n", + " πŸ“Š Daily report: 22:00 UTC\n", + " πŸ“ˆ Weekly report: Sunday 23:00 UTC\n", + "βœ… Scheduled reports added:\n", + " πŸ“Š Daily report: 22:00 UTC\n", + " πŸ“ˆ Weekly report: Sunday 23:00 UTC\n", + "βœ… Position Monitor job added\n", + "βœ… Advanced Position Management job added\n", + "\n", + "βœ… Scheduler started!\n", + "\n", + "πŸ“‹ Active Jobs: 6\n", + " β€’ adaptive_trading_check\n", + " β€’ position_monitor\n", + " β€’ advanced_position_management\n", + " β€’ status_report\n", + " β€’ daily_report\n", + " β€’ weekly_report\n", + "\n", + "======================================================================\n", + "πŸš€ TradingBot V2.2 - All Systems Ready!\n", + "======================================================================\n" + ] + } + ], "source": [ "# ==========================================\n", "# SETUP SCHEDULER (V1.6 ADAPTIVE COMPLETE)\n", @@ -2478,9 +3167,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 89, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ§ͺ TEST 1: Position Check\n", + "==================================================\n", + "\n", + "πŸ“Š POSITION SUMMARY fΓΌr XAUUSD (V1.6 Adaptive Complete)\n", + "============================================================\n", + "βœ… Keine aktiven Positionen - bereit fΓΌr neuen Trade\n" + ] + }, + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# βœ… KORRIGIERT: Umfassende Testing Suite (fehlte in V1.6)\n", "\n", @@ -2492,9 +3204,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 90, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ§ͺ TEST 2: Adaptive Rhythm\n", + "==================================================\n", + "\n", + "╔════════════════════════════════════════════════════════╗\n", + "β•‘ ADAPTIVE RHYTHM STATUS - 17:10:00 UTC β•‘\n", + "╠════════════════════════════════════════════════════════╣\n", + "β•‘ Aktuelles Intervall: 5 Minuten β•‘\n", + "β•‘ Trading Session: NY β•‘\n", + "β•‘ VolatilitΓ€tslevel: HIGH β•‘\n", + "β•‘ ATR (H1): 88.26 β•‘\n", + "╠════════════════════════════════════════════════════════╣\n", + "β•‘ INTERVALL-SCHEMA: β•‘\n", + "β•‘ β€’ Overlap (13-16 UTC): 5-15 Min (aktivste Phase) β•‘\n", + "β•‘ β€’ London/NY: 5-30 Min (volatilitΓ€tsabh.) β•‘\n", + "β•‘ β€’ Asian Session: 15-30 Min (ruhigere Phase) β•‘\n", + "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•\n", + "\n", + "\n", + "Details:\n", + " Optimal Interval: 5 min\n", + " Session: ny\n", + " ATR: 88.26\n", + " Volatility Level: high\n" + ] + } + ], "source": [ "# Test 2: Adaptive Rhythm Status\n", "print(\"\\nπŸ§ͺ TEST 2: Adaptive Rhythm\")\n", @@ -2518,9 +3261,56 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 91, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ§ͺ TEST 3: Signal Analysis\n", + "==================================================\n", + "πŸ” Analyzing XAUUSD with V1.6 ADAPTIVE COMPLETE parameters...\n", + "\n", + "πŸ“Š V1.6 ADAPTIVE COMPLETE Trend-Analyse fΓΌr XAUUSD\n", + "⚑ Adaptive Interval: 5 min | Session: NY\n", + "🎯 Market Regime: RANGING (Strength: 22%)\n", + "🎚️ Adaptive Threshold: 70% (RELAXED)\n", + "\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "| TF | Trend | Strength | ATR | Slope | Price |\n", + "|------+-----------+------------+----------+-----------+---------|\n", + "| D1 | uptrend | 438.23 | 166.05 | 10.9151 | 5033.55 |\n", + "| H4 | uptrend | 331.98 | 127.543 | 6.3513 | 5033.53 |\n", + "| H1 | uptrend | 265.09 | 87.4591 | 3.47763 | 5033.57 |\n", + "| M30 | uptrend | 52.08 | 65.4288 | 0.511174 | 5033.57 |\n", + "| M15 | downtrend | 568.5 | 46.2663 | -3.94538 | 5033.56 |\n", + "| M5 | downtrend | 336.77 | 25.1103 | -1.26847 | 5033.53 |\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "\n", + "➑️ Standard-Trend: uptrend (Strength: 395.73)\n", + "➑️ Fast-Trend: downtrend (Required: 2/4)\n", + "➑️ Top-Down-Trend: sideways\n", + "➑️ Confidence: 0.0% (Threshold: 70%)\n", + "➑️ Risk-Adjusted Strength: 0.0 (Min: 80)\n", + "➑️ Signal Quality: NONE\n", + "\n", + "πŸš€ V1.6 Adaptive Complete: Full Features + Adaptive Rhythm\n", + "\n", + "🎯 SIGNAL SUMMARY:\n", + " Entry Signal: 0\n", + " Confidence: 0.0%\n", + " Threshold: 70%\n", + " Quality: NONE\n", + " Regime: RANGING\n", + " Adaptive Interval: 5 min\n", + " Session: NY\n", + "\n", + "⏸️ NO TRADING SIGNAL\n" + ] + } + ], "source": [ "# Test 3: Signal Analysis\n", "print(\"\\nπŸ§ͺ TEST 3: Signal Analysis\")\n", @@ -2549,9 +3339,78 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 92, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ§ͺ TEST 4: Complete Bot Status\n", + "==================================================\n", + "\n", + "======================================================================\n", + "πŸ” V1.6 ADAPTIVE COMPLETE BOT STATUS\n", + "======================================================================\n", + "\n", + "πŸ“‘ SYSTEM STATUS:\n", + " MT5 Connection: βœ…\n", + " Scheduler Running: βœ…\n", + " Active Jobs: 6\n", + "\n", + "⚑ ADAPTIVE RHYTHM:\n", + " Current Interval: 5 min\n", + " Trading Session: NY\n", + " ATR (H1): 88.26\n", + " Volatility: HIGH\n", + "\n", + "πŸ›‘οΈ POSITION CONTROL:\n", + " Active Positions: 0/1\n", + " Trading Status: βœ… READY\n", + "\n", + "πŸ“Š CURRENT SIGNAL:\n", + "πŸ” Analyzing XAUUSD with V1.6 ADAPTIVE COMPLETE parameters...\n", + "\n", + "πŸ“Š V1.6 ADAPTIVE COMPLETE Trend-Analyse fΓΌr XAUUSD\n", + "⚑ Adaptive Interval: 5 min | Session: NY\n", + "🎯 Market Regime: RANGING (Strength: 22%)\n", + "🎚️ Adaptive Threshold: 70% (RELAXED)\n", + "\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "| TF | Trend | Strength | ATR | Slope | Price |\n", + "|------+-----------+------------+----------+-----------+---------|\n", + "| D1 | uptrend | 438.22 | 166.05 | 10.9151 | 5033.42 |\n", + "| H4 | uptrend | 331.98 | 127.543 | 6.35127 | 5033.42 |\n", + "| H1 | uptrend | 265.08 | 87.4591 | 3.47759 | 5033.42 |\n", + "| M30 | uptrend | 52.08 | 65.4288 | 0.511138 | 5033.42 |\n", + "| M15 | downtrend | 568.51 | 46.2663 | -3.94541 | 5033.42 |\n", + "| M5 | downtrend | 336.78 | 25.1103 | -1.2685 | 5033.42 |\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "\n", + "➑️ Standard-Trend: uptrend (Strength: 395.73)\n", + "➑️ Fast-Trend: downtrend (Required: 2/4)\n", + "➑️ Top-Down-Trend: sideways\n", + "➑️ Confidence: 0.0% (Threshold: 70%)\n", + "➑️ Risk-Adjusted Strength: 0.0 (Min: 80)\n", + "➑️ Signal Quality: NONE\n", + "\n", + "πŸš€ V1.6 Adaptive Complete: Full Features + Adaptive Rhythm\n", + " Signal: NONE\n", + " Confidence: 0.0%\n", + " Threshold: 70%\n", + " Quality: NONE\n", + " Regime: RANGING\n", + " Would Trade: ❌ NO\n", + "\n", + "πŸŽ‰ VERSION INFO:\n", + " Version: V1.6 Adaptive Complete (CORRECTED)\n", + " Features: Position Control + Relaxed + Adaptive Rhythm\n", + " Status: Production-Ready βœ…\n", + "======================================================================\n" + ] + } + ], "source": [ "# Test 4: Complete Bot Status\n", "print(\"\\nπŸ§ͺ TEST 4: Complete Bot Status\")\n", @@ -2561,9 +3420,70 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 93, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ§ͺ TEST 5: Trade Execution (DRY RUN)\n", + "==================================================\n", + "\n", + "Testing trading logic without actual order...\n", + "\n", + "πŸ“Š MULTI-TIMEFRAME REGIME CHECK\n", + "============================================================\n", + " H1: ADX 52.4 (weight 1.0x) βœ… TREND\n", + " H4: ADX 38.6 (weight 2.0x) βœ… TREND\n", + " D1: ADX 47.5 (weight 3.0x) βœ… TREND\n", + "\n", + " Weighted ADX: 45.3\n", + " Threshold: 25\n", + "\n", + " βœ… ALLOWED: TRENDING\n", + " Reason: D1 stark trending (ADX 47.5 > 30) β†’ Trend dominiert\n", + "============================================================\n", + "\n", + "βœ… REGIME CHECK PASSED: TRENDING\n", + " Reason: D1 stark trending (ADX 47.5 > 30) β†’ Trend dominiert\n", + "\n", + "πŸ” POSITION CHECK fΓΌr XAUUSD (V1.6 Adaptive Complete)\n", + "βœ… Position-Check OK: 0/1\n", + "πŸ” Analyzing XAUUSD with V1.6 ADAPTIVE COMPLETE parameters...\n", + "\n", + "πŸ“Š V1.6 ADAPTIVE COMPLETE Trend-Analyse fΓΌr XAUUSD\n", + "⚑ Adaptive Interval: 5 min | Session: NY\n", + "🎯 Market Regime: RANGING (Strength: 22%)\n", + "🎚️ Adaptive Threshold: 70% (RELAXED)\n", + "\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "| TF | Trend | Strength | ATR | Slope | Price |\n", + "|------+-----------+------------+----------+-----------+---------|\n", + "| D1 | uptrend | 438.22 | 166.05 | 10.9151 | 5033.42 |\n", + "| H4 | uptrend | 331.98 | 127.543 | 6.35127 | 5033.42 |\n", + "| H1 | uptrend | 265.08 | 87.4591 | 3.47759 | 5033.42 |\n", + "| M30 | uptrend | 52.08 | 65.4288 | 0.511138 | 5033.42 |\n", + "| M15 | downtrend | 568.51 | 46.2663 | -3.94541 | 5033.42 |\n", + "| M5 | downtrend | 336.78 | 25.1103 | -1.2685 | 5033.42 |\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "\n", + "➑️ Standard-Trend: uptrend (Strength: 395.73)\n", + "➑️ Fast-Trend: downtrend (Required: 2/4)\n", + "➑️ Top-Down-Trend: sideways\n", + "➑️ Confidence: 0.0% (Threshold: 70%)\n", + "➑️ Risk-Adjusted Strength: 0.0 (Min: 80)\n", + "➑️ Signal Quality: NONE\n", + "\n", + "πŸš€ V1.6 Adaptive Complete: Full Features + Adaptive Rhythm\n", + "\n", + "⏸️ TRADE SKIPPED: Confidence 0.0% < threshold 70%\n", + "\n", + "⏸️ Kein Trade - Bedingungen nicht erfΓΌllt\n" + ] + } + ], "source": [ "# Test 5: Trade Execution Test (DRY RUN)\n", "print(\"\\nπŸ§ͺ TEST 5: Trade Execution (DRY RUN)\")\n", @@ -2591,27 +3511,140 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 94, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[.protected_check)>,\n", + " ,\n", + " )>,\n", + " ,\n", + " ,\n", + " ]" + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "scheduler.get_jobs()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 95, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ“Š MULTI-TIMEFRAME REGIME CHECK\n", + "============================================================\n", + " H1: ADX 52.4 (weight 1.0x) βœ… TREND\n", + " H4: ADX 38.6 (weight 2.0x) βœ… TREND\n", + " D1: ADX 47.5 (weight 3.0x) βœ… TREND\n", + "\n", + " Weighted ADX: 45.3\n", + " Threshold: 25\n", + "\n", + " βœ… ALLOWED: TRENDING\n", + " Reason: D1 stark trending (ADX 47.5 > 30) β†’ Trend dominiert\n", + "============================================================\n", + "\n", + "βœ… REGIME CHECK PASSED: TRENDING\n", + " Reason: D1 stark trending (ADX 47.5 > 30) β†’ Trend dominiert\n", + "\n", + "πŸ” POSITION CHECK fΓΌr XAUUSD (V1.6 Adaptive Complete)\n", + "βœ… Position-Check OK: 0/1\n", + "πŸ” Analyzing XAUUSD with V1.6 ADAPTIVE COMPLETE parameters...\n", + "\n", + "πŸ“Š V1.6 ADAPTIVE COMPLETE Trend-Analyse fΓΌr XAUUSD\n", + "⚑ Adaptive Interval: 5 min | Session: NY\n", + "🎯 Market Regime: RANGING (Strength: 22%)\n", + "🎚️ Adaptive Threshold: 70% (RELAXED)\n", + "\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "| TF | Trend | Strength | ATR | Slope | Price |\n", + "|------+-----------+------------+----------+-----------+---------|\n", + "| D1 | uptrend | 438.23 | 166.05 | 10.9151 | 5033.48 |\n", + "| H4 | uptrend | 331.98 | 127.543 | 6.35128 | 5033.48 |\n", + "| H1 | uptrend | 265.08 | 87.4591 | 3.47761 | 5033.48 |\n", + "| M30 | uptrend | 52.08 | 65.4288 | 0.511153 | 5033.48 |\n", + "| M15 | downtrend | 568.51 | 46.2663 | -3.9454 | 5033.48 |\n", + "| M5 | downtrend | 336.78 | 25.1103 | -1.26849 | 5033.48 |\n", + "+------+-----------+------------+----------+-----------+---------+\n", + "\n", + "➑️ Standard-Trend: uptrend (Strength: 395.73)\n", + "➑️ Fast-Trend: downtrend (Required: 2/4)\n", + "➑️ Top-Down-Trend: sideways\n", + "➑️ Confidence: 0.0% (Threshold: 70%)\n", + "➑️ Risk-Adjusted Strength: 0.0 (Min: 80)\n", + "➑️ Signal Quality: NONE\n", + "\n", + "πŸš€ V1.6 Adaptive Complete: Full Features + Adaptive Rhythm\n", + "\n", + "⏸️ TRADE SKIPPED: Confidence 0.0% < threshold 70%\n" + ] + } + ], "source": [ "execute_trade_v2_adaptive(**ADAPTIVE_COMPLETE_CONFIG)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 96, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "======================================================================\n", + "πŸ”§ V1.6 ADAPTIVE COMPLETE - MANAGEMENT CONTROL PANEL\n", + "======================================================================\n", + "\n", + "πŸ“Š MONITORING:\n", + " 1. check_adaptive_bot_status() - Complete Status\n", + " 2. get_position_summary() - Position Overview\n", + " 3. print_status_report() - Adaptive Rhythm Status\n", + " 4. analyze_performance_adaptive() - Performance Analysis\n", + "\n", + "🎯 ANALYSIS:\n", + " 5. extended_top_down_v2_adaptive() - Signal Analysis\n", + " 6. rhythm_manager.calculate_optimal_interval() - Current Interval\n", + "\n", + "πŸ’Ό POSITION MANAGEMENT:\n", + " 7. close_existing_positions(force_close=True) - Close All Positions\n", + "\n", + "πŸš€ TRADING:\n", + " 8. execute_trade_v2_adaptive(**ADAPTIVE_COMPLETE_CONFIG) - Manual Trade\n", + "\n", + "βš™οΈ SCHEDULER CONTROL:\n", + " 9. scheduler.get_jobs() - Show Active Jobs\n", + " 10. scheduler.pause() - Pause Scheduler\n", + " 11. scheduler.resume() - Resume Scheduler\n", + " 12. scheduler.shutdown() - Stop Scheduler\n", + "\n", + "πŸ”§ CONFIGURATION:\n", + " 13. ADAPTIVE_COMPLETE_CONFIG - View Config\n", + " 14. rhythm_manager.atr_thresholds - ATR Settings\n", + "\n", + "πŸ“ QUICK COMMANDS:\n", + " β€’ Status: check_adaptive_bot_status()\n", + " β€’ Close: close_existing_positions(symbol, strategy_name, force_close=True)\n", + " β€’ Stop: scheduler.shutdown()\n", + "======================================================================\n" + ] + } + ], "source": [ "# βœ… KORRIGIERT: Management Control Panel (fehlte in V1.6)\n", "def show_adaptive_management_options():\n", @@ -2661,9 +3694,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 97, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ’‘ To close positions manually, uncomment the code above\n" + ] + } + ], "source": [ "# Optional: Close positions manually\n", "# UNCOMMENT to use:\n", @@ -2674,9 +3715,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 98, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ’‘ To adjust ATR thresholds, uncomment the code above\n" + ] + } + ], "source": [ "# Optional: ATR-Schwellenwerte anpassen\n", "# UNCOMMENT to use:\n", @@ -2692,9 +3741,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 99, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸŽ›οΈ SCHEDULER CONTROL\n", + "\n", + "πŸ’‘ To pause trading:\n", + "scheduler.pause()\n", + "\n", + "πŸ’‘ To resume trading:\n", + "scheduler.resume()\n", + "\n", + "πŸ’‘ To stop completely:\n", + "scheduler.shutdown()\n" + ] + } + ], "source": [ "# Scheduler Control\n", "print(\"πŸŽ›οΈ SCHEDULER CONTROL\")\n", @@ -2719,9 +3785,92 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 100, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "======================================================================\n", + "πŸ“ˆ TRADINGBOT V1.6 ADAPTIVE COMPLETE - SUMMARY\n", + "======================================================================\n", + "\n", + "πŸŽ‰ VERSION: V1.6 ADAPTIVE COMPLETE (CORRECTED & READY!)\n", + "\n", + "βœ… ALLE FEATURES INTEGRIERT:\n", + "\n", + "πŸ›‘οΈ Position Control (aus V1.5):\n", + " β€’ Maximal 1 Trade gleichzeitig\n", + " β€’ check_existing_positions()\n", + " β€’ get_position_summary()\n", + " β€’ close_existing_positions() βœ… KORRIGIERT!\n", + "\n", + "πŸš€ Relaxed Trading Parameters (aus V1.5):\n", + " β€’ 10-20% niedrigere Confidence-Schwellen\n", + " β€’ Disabled Pullback Entry\n", + " β€’ Relaxed Signal-Quality-Filter\n", + " β€’ Niedrigere Min Risk-Adjusted Strength (80)\n", + " β€’ Fixed 2/4 Timeframe Alignment\n", + "\n", + "⚑ Adaptive Rhythm (NEU in V1.6):\n", + " β€’ Adaptive Intervalle: 5/15/30 Minuten\n", + " β€’ VolatilitΓ€ts-basiert (ATR)\n", + " β€’ Session-abhΓ€ngig (Asian/London/NY/Overlap)\n", + " β€’ Intelligente Entscheidungs-Matrix\n", + "\n", + "πŸ“Š Monitoring & Management (aus V1.5, angepasst):\n", + " β€’ Performance Logging\n", + " β€’ Performance Analysis\n", + " β€’ Complete Status Monitoring βœ… KORRIGIERT!\n", + " β€’ Management Control Panel βœ… KORRIGIERT!\n", + "\n", + "πŸ€– Automation:\n", + " β€’ APScheduler Integration\n", + " β€’ Adaptive Trading Checks (jede Minute)\n", + " β€’ Status Reports (alle 30 Min)\n", + "\n", + "πŸ§ͺ Testing Suite (aus V1.5):\n", + " β€’ Position Tests βœ… KORRIGIERT!\n", + " β€’ Signal Analysis Tests βœ… KORRIGIERT!\n", + " β€’ Adaptive Rhythm Tests\n", + " β€’ Complete Status Tests βœ… KORRIGIERT!\n", + "\n", + "βš™οΈ Configuration:\n", + " β€’ ADAPTIVE_COMPLETE_CONFIG βœ… KORRIGIERT!\n", + " β€’ Zentrale Parameter-Verwaltung\n", + "\n", + "🎯 VORTEILE VON V1.6 ADAPTIVE COMPLETE:\n", + " βœ… Maximale Sicherheit (Position Control)\n", + " βœ… Maximale Gelegenheiten (Relaxed Parameters)\n", + " βœ… Maximale Effizienz (Adaptive Rhythm)\n", + " βœ… VollstΓ€ndige Kontrolle (Complete Management)\n", + " βœ… Production-Ready!\n", + "\n", + "πŸ“Š TYPISCHER 24H-ZYKLUS:\n", + " 00:00-08:00 (Asian) β†’ 15-30 min\n", + " 08:00-13:00 (London) β†’ 5-30 min\n", + " 13:00-16:00 (Overlap) β†’ 5-15 min πŸ”₯\n", + " 16:00-21:00 (NY) β†’ 5-30 min\n", + " 21:00-00:00 (After) β†’ 15-30 min\n", + "\n", + "πŸ’‘ HAUPTFUNKTIONEN:\n", + " β€’ Status: check_adaptive_bot_status()\n", + " β€’ Analyze: extended_top_down_v2_adaptive()\n", + " β€’ Trade: execute_trade_v2_adaptive()\n", + " β€’ Manage: show_adaptive_management_options()\n", + "\n", + "πŸ† V1.6 ADAPTIVE COMPLETE - ALLE FUNKTIONEN INTEGRIERT!\n", + " πŸ›‘οΈ Sicherheit + πŸš€ AggressivitΓ€t + ⚑ Intelligenz\n", + " Production-Ready & Fully Tested! βœ…\n", + "\n", + "======================================================================\n", + "🎊 Ready for intelligent, safe, and adaptive trading!\n", + "======================================================================\n" + ] + } + ], "source": [ "print(\"\\n\" + \"=\"*70)\n", "print(\"πŸ“ˆ TRADINGBOT V1.6 ADAPTIVE COMPLETE - SUMMARY\")\n", @@ -2809,9 +3958,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 101, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ” Drawdown Protection Debug:\n", + " trading_paused: False\n", + " pause_until: None\n", + " pause_reason: None\n", + "\n", + "βœ… After force clear:\n", + " Can trade: True\n", + " Reason: OK\n", + "\n", + "πŸ“Š Consecutive losses from DB: 0\n" + ] + } + ], "source": [ "# Check Drawdown Protection Status\n", "print(\"πŸ” Drawdown Protection Debug:\")\n", @@ -2844,7 +4010,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 102, "metadata": {}, "outputs": [], "source": [ @@ -2928,9 +4094,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 103, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'enabled_sessions': {'asian': True, 'london': False, 'overlap': True, 'ny': True}, 'session_confidence_thresholds': {'asian': 95, 'ny': 97, 'london': 95, 'overlap': 95}, 'base_confidence': 95, 'atr_mult': 1.5, 'max_risk_per_trade': 0.02, 'min_atr': 0.0008, 'min_lot': 0.1, 'max_lot': 0.2, 'default_lot': 0.1, 'risk_filter': True, 'use_pullback_entry': False, 'debug': True}\n", + "βœ… asian: Asian allowed: 97.8% WR, $151/trade (EXCELLENT!)\n", + "❌ london: London blocked: 12.5% win-rate, -$10/trade\n", + "βœ… overlap: Overlap allowed: 14.3% WR (low)\n", + "βœ… ny: NY allowed: 43.3% WR, $48/trade (needs >=97% conf)\n" + ] + } + ], "source": [ "# PrΓΌfe ob Filter aktiv ist\n", "print(SESSION_WHITELIST_CONFIG)\n", @@ -2944,9 +4122,60 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 104, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“Š ADX auf verschiedenen Timeframes:\n", + "\n", + "M15 : ADX = 41.27 | Preis-Change (10 bars): +0.28%\n", + "H1 : ADX = 52.36 | Preis-Change (10 bars): -2.85%\n", + "H4 : ADX = 38.63 | Preis-Change (10 bars): -9.51%\n", + "D1 : ADX = 47.48 | Preis-Change (10 bars): +7.76%\n", + "\n", + "πŸ’° Aktueller Preis: 5033.44\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:04,695 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:04,698 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n" + ] + } + ], "source": [ "# Verschiedene Timeframes checken\n", "print(\"πŸ“Š ADX auf verschiedenen Timeframes:\\n\")\n", @@ -2968,9 +4197,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 105, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:04,713 - INFO - πŸ“Š Adaptive Position Sizing:\n", + "2026-01-30 17:10:04,715 - INFO - Confidence: 85.0% (HIGH)\n", + "2026-01-30 17:10:04,715 - INFO - Base Risk: 2.0%\n", + "2026-01-30 17:10:04,716 - INFO - Multiplier: 1.5x\n", + "2026-01-30 17:10:04,729 - INFO - Adjusted Risk: 3.0%\n", + "2026-01-30 17:10:04,730 - INFO - πŸ’° Position Size: 0.20 lots\n", + "2026-01-30 17:10:04,731 - INFO - Risk Amount: $300.00\n", + "2026-01-30 17:10:04,733 - INFO - SL Distance: 50.00 pips\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Base Risk: 0.02\n", + "Test Volume: 0.2\n" + ] + } + ], "source": [ "# Check 1: Base Risk\n", "print(f\"Base Risk: {adv_position_mgr.adaptive_sizing.base_risk}\")\n", @@ -3011,7 +4263,759 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-01-30 17:10:05,729 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:05,731 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:10,267 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:10,282 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:11,813 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:11,813 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:17,128 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:17,128 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:19,406 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:19,406 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:22,808 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:22,808 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:26,208 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:26,208 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:31,370 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:31,370 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:36,504 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:36,504 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:40,794 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:11:40 CET)\" (scheduled at 2026-01-30 17:10:40.794207+01:00)\n", + "2026-01-30 17:10:40,796 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:11:40 CET)\" executed successfully\n", + "2026-01-30 17:10:40,811 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:11:40 CET)\" (scheduled at 2026-01-30 17:10:40.796150+01:00)\n", + "2026-01-30 17:10:40,812 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:11:40 CET)\" executed successfully\n", + "2026-01-30 17:10:44,171 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:44,171 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:10:51,838 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:10:51,838 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:11:00,003 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:11:00 CET)\" (scheduled at 2026-01-30 17:11:00+01:00)\n", + "2026-01-30 17:11:00,106 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:12:00 CET)\" executed successfully\n", + "2026-01-30 17:11:00,169 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:12:00 CET)\" (scheduled at 2026-01-30 17:11:00+01:00)\n", + "2026-01-30 17:11:00,179 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:12:00 CET)\" executed successfully\n", + "2026-01-30 17:11:01,029 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:12:00 CET)\" (scheduled at 2026-01-30 17:11:00.592638+01:00)\n", + "2026-01-30 17:11:01,029 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:12:00 CET)\" executed successfully\n", + "2026-01-30 17:11:01,213 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:11:00 CET)\" (scheduled at 2026-01-30 17:11:00.594641+01:00)\n", + "2026-01-30 17:11:01,236 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:12:00 CET)\" executed successfully\n", + "2026-01-30 17:11:01,839 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:11:03,286 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:11:03,296 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:11:07,314 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:11:07,327 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:11:14,328 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:11:24,359 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:11:24,508 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:11:24,511 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:11:28,546 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:11:28,546 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:11:35,546 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:11:40,861 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:12:40 CET)\" (scheduled at 2026-01-30 17:11:40.794207+01:00)\n", + "2026-01-30 17:11:40,861 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:12:40 CET)\" executed successfully\n", + "2026-01-30 17:11:40,861 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:12:40 CET)\" (scheduled at 2026-01-30 17:11:40.796150+01:00)\n", + "2026-01-30 17:11:40,861 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:12:40 CET)\" executed successfully\n", + "2026-01-30 17:11:45,573 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:11:54,265 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:11:54,265 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:11:58,296 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:11:58,296 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:12:00,037 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:13:00 CET)\" (scheduled at 2026-01-30 17:12:00+01:00)\n", + "2026-01-30 17:12:00,046 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:13:00 CET)\" executed successfully\n", + "2026-01-30 17:12:00,096 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:13:00 CET)\" (scheduled at 2026-01-30 17:12:00+01:00)\n", + "2026-01-30 17:12:00,120 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:13:00 CET)\" executed successfully\n", + "2026-01-30 17:12:00,743 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:00 CET)\" (scheduled at 2026-01-30 17:12:00.592638+01:00)\n", + "2026-01-30 17:12:00,743 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:00 CET)\" (scheduled at 2026-01-30 17:12:00.594641+01:00)\n", + "2026-01-30 17:12:00,743 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:00 CET)\" executed successfully\n", + "2026-01-30 17:12:00,759 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:00 CET)\" executed successfully\n", + "2026-01-30 17:12:05,296 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:12:15,328 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:12:25,356 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:12:28,631 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:12:28,659 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:12:32,690 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:12:32,692 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:12:39,682 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:12:41,159 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:40 CET)\" (scheduled at 2026-01-30 17:12:40.794207+01:00)\n", + "2026-01-30 17:12:41,162 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:40 CET)\" executed successfully\n", + "2026-01-30 17:12:41,164 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:40 CET)\" (scheduled at 2026-01-30 17:12:40.796150+01:00)\n", + "2026-01-30 17:12:41,165 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:13:40 CET)\" executed successfully\n", + "2026-01-30 17:12:49,730 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:12:59,755 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:13:00,061 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:14:00 CET)\" (scheduled at 2026-01-30 17:13:00+01:00)\n", + "2026-01-30 17:13:00,061 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:14:00 CET)\" executed successfully\n", + "2026-01-30 17:13:00,481 - INFO - Running job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:14:00 CET)\" (scheduled at 2026-01-30 17:13:00+01:00)\n", + "2026-01-30 17:13:00,508 - INFO - Job \"create_protected_trading_check..protected_check (trigger: cron[minute='*'], next run at: 2026-01-30 17:14:00 CET)\" executed successfully\n", + "2026-01-30 17:13:00,996 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:00 CET)\" (scheduled at 2026-01-30 17:13:00.592638+01:00)\n", + "2026-01-30 17:13:00,997 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:00 CET)\" (scheduled at 2026-01-30 17:13:00.594641+01:00)\n", + "2026-01-30 17:13:01,000 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:00 CET)\" executed successfully\n", + "2026-01-30 17:13:00,999 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:00 CET)\" executed successfully\n", + "2026-01-30 17:13:02,764 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:13:02,764 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:13:06,789 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:13:06,791 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:13:13,788 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:13:23,810 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:13:33,834 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", + "2026-01-30 17:13:36,883 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:13:36,886 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:13:40,831 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:40 CET)\" (scheduled at 2026-01-30 17:13:40.794207+01:00)\n", + "2026-01-30 17:13:40,832 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:40 CET)\" executed successfully\n", + "2026-01-30 17:13:40,834 - INFO - Running job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:40 CET)\" (scheduled at 2026-01-30 17:13:40.796150+01:00)\n", + "2026-01-30 17:13:40,835 - INFO - Job \" (trigger: interval[0:01:00], next run at: 2026-01-30 17:14:40 CET)\" executed successfully\n", + "2026-01-30 17:13:40,909 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 409 Conflict\"\n", + "2026-01-30 17:13:40,912 - ERROR - Exception happened while polling for updates.\n", + "Traceback (most recent call last):\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 161, in network_retry_loop\n", + " await do_action()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_utils\\networkloop.py\", line 154, in do_action\n", + " action_cb_task.result()\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_updater.py\", line 340, in polling_action_cb\n", + " updates = await self.bot.get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 671, in get_updates\n", + " updates = await super().get_updates(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 4860, in get_updates\n", + " await self._post(\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 703, in _post\n", + " return await self._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\ext\\_extbot.py\", line 369, in _do_post\n", + " return await super()._do_post(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\_bot.py\", line 732, in _do_post\n", + " result = await request.post(\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 198, in post\n", + " result = await self._request_wrapper(\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"c:\\ProgramData\\anaconda3\\Lib\\site-packages\\telegram\\request\\_baserequest.py\", line 375, in _request_wrapper\n", + " raise exception\n", + "telegram.error.Conflict: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running\n", + "2026-01-30 17:13:47,941 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n" + ] + } + ], "source": [ "# ==========================================\n", "# ADVANCED OPTIMIZATION SETUP (V1.8)\n", @@ -3023,6 +5027,7 @@ "from equity_curve_trading import EquityCurveManager\n", "from demo_test_tracker import DemoTestTracker\n", "from reversal_integration import check_reversal_risk, get_reversal_status, REVERSAL_CONFIG\n", + "from loss_protection_manager import LossProtectionManager\n", "\n", "print(\"πŸš€ INITIALIZING ADVANCED OPTIMIZATIONS...\")\n", "print(\"=\" * 70)\n", @@ -3119,6 +5124,20 @@ "print(\"βœ… Reversal Detector initialized\")\n", "print(get_reversal_status())\n", "\n", + "# 7. Loss Protection Manager\n", + "loss_protection_manager = LossProtectionManager(\n", + " daily_loss_limit_pct=2.0, # Max 2% daily loss\n", + " daily_loss_limit_dollars=500.0, # Max $500 daily loss\n", + " max_consecutive_losses=3, # Pause after 3 losses\n", + " cooldown_minutes=120, # 2h cooldown\n", + " max_drawdown_pct=10.0, # 10% circuit breaker\n", + " news_filter_enabled=True, # Filter high-impact news\n", + " news_buffer_minutes=30, # 30min buffer\n", + " account_balance=100000.0 # Will be updated from MT5\n", + ")\n", + "print(\"βœ… Loss Protection Manager initialized\")\n", + "print(loss_protection_manager.get_report())\n", + "\n", "# 4. Run initial threshold optimization\n", "print(\"πŸ”„ Running initial threshold optimization...\")\n", "try:\n", @@ -3139,6 +5158,7 @@ "print(\" β€’ Equity Curve Trading: βœ… (auto-pause on drawdown)\")\n", "print(\" β€’ Demo Test Tracker: βœ… (go-live readiness check)\")\n", "print(\" β€’ Reversal Detector: βœ… (multi-signal protection)\")\n", + "print(\" β€’ Loss Protection: βœ… (daily limit, consecutive, drawdown, news)\")\n", "print()\n", "print(\"πŸ’‘ Tip: Use 'threshold_optimizer.generate_report()' for details\")" ] @@ -3688,6 +5708,18 @@ " \n", " print(f\"βœ… Session OK: {current_session.upper()}\")\n", "\n", + " # ==========================================\n", + " # ⭐ SCHRITT 0.5: LOSS PROTECTION CHECK (NEU!)\n", + " # ==========================================\n", + " lp_allowed, lp_reason, lp_multiplier = loss_protection_manager.check_trading_allowed()\n", + "\n", + " print(f\"πŸ›‘οΈ Loss Protection: {lp_reason}\")\n", + "\n", + " if not lp_allowed:\n", + " print(f\"β›” TRADE BLOCKIERT durch Loss Protection!\")\n", + " return None\n", + "\n", + "\n", " # SCHRITT 1: Position Check (wie vorher)\n", " max_positions = TRADING_CONFIG['risk']['max_positions']\n", " has_position, position_info = check_existing_positions(symbol)\n", @@ -3745,6 +5777,11 @@ " lot_multiplier *= reversal_result['lot_multiplier']\n", " print(f\"πŸ“‰ Reversal: Lot Multiplier angepasst auf {lot_multiplier:.0%}\")\n", "\n", + " # Apply Loss Protection multiplier\n", + " if lp_multiplier < 1.0:\n", + " lot_multiplier *= lp_multiplier\n", + " print(f\"πŸ›‘οΈ Loss Protection: Lot angepasst auf {lot_multiplier:.0%}\")\n", + "\n", " # ⭐ SCHRITT 3: ENHANCED SIGNAL SCORING (HYBRID 60/40)\n", " print(f\"\\n🎯 Calculating Enhanced Signal Score...\")\n", "\n", @@ -4497,15 +6534,7 @@ "execution_count": null, "id": "cf605503", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:33:47,749 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n" - ] - } - ], + "outputs": [], "source": [ "# ==========================================\n", "# πŸ’° P&L PERFORMANCE DASHBOARD\n", @@ -4545,460 +6574,6 @@ "print(\"=\" * 80)\n" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "πŸ§ͺ Testing Reversal Detector...\n", - "============================================================\n", - "βœ… Import erfolgreich\n", - "\n", - "============================================================\n", - "πŸ”„ REVERSAL DETECTOR STATUS\n", - "============================================================\n", - " Enabled: True\n", - " Mode: defensive\n", - " Block Threshold: 70%\n", - " Reduce Threshold: 50%\n", - " Caution Threshold: 30%\n", - "============================================================\n", - "\n", - "πŸ” Testing with live market data...\n", - "πŸ” Analyzing XAUUSD with V1.6 ADAPTIVE COMPLETE parameters...\n", - "\n", - "πŸ“Š V1.6 ADAPTIVE COMPLETE Trend-Analyse fΓΌr XAUUSD\n", - "⚑ Adaptive Interval: 5 min | Session: LONDON\n", - "🎯 Market Regime: RANGING (Strength: 21%)\n", - "🎚️ Adaptive Threshold: 70% (RELAXED)\n", - "\n", - "+------+-----------+------------+----------+----------+---------+\n", - "| TF | Trend | Strength | ATR | Slope | Price |\n", - "|------+-----------+------------+----------+----------+---------|\n", - "| D1 | uptrend | 463.42 | 157.145 | 10.9236 | 5069.5 |\n", - "| H4 | uptrend | 362.48 | 116.225 | 6.31934 | 5069.18 |\n", - "| H1 | uptrend | 349.09 | 82.1467 | 4.30149 | 5069.18 |\n", - "| M30 | uptrend | 228.93 | 63.3682 | 2.17604 | 5069.18 |\n", - "| M15 | downtrend | 273.87 | 44.4494 | -1.82601 | 5068.79 |\n", - "| M5 | downtrend | 490.87 | 25.6075 | -1.88549 | 5068.66 |\n", - "+------+-----------+------------+----------+----------+---------+\n", - "\n", - "➑️ Standard-Trend: uptrend (Strength: 423.04)\n", - "➑️ Fast-Trend: uptrend (Required: 2/4)\n", - "➑️ Top-Down-Trend: uptrend\n", - "➑️ Confidence: 83.69% (Threshold: 70%)\n", - "➑️ Risk-Adjusted Strength: 79947.2 (Min: 80)\n", - "➑️ Signal Quality: EXCELLENT\n", - "\n", - "πŸš€ V1.6 Adaptive Complete: Full Features + Adaptive Rhythm\n", - "\n", - "πŸ“Š Signal Info:\n", - " Entry Signal: 1\n", - " Standard Trend: uptrend\n", - " Confidence: 83.69%\n", - "\n", - "πŸ”„ Running Reversal Check...\n", - "\n", - "πŸ”„ REVERSAL CHECK (UPTREND):\n", - "--------------------------------------------------\n", - " Rsi Divergence : βœ… No divergence\n", - " Ema Slope Change : ⚠️ Slope weakening: -0.1010% -> -0.4427%\n", - " Strength: 100%\n", - " Volume Spike : βœ… Volume: 0.4x average\n", - " Candlestick : ⚠️ Bearish Engulfing: Strong reversal signal\n", - " Strength: 70%\n", - " Break Of Structure : βœ… Structure intact\n", - "--------------------------------------------------\n", - " ⚠️ Reversal Score: 30% (MODERATE)\n", - " Action: CAUTION | Lot Mult: 75%\n", - "\n", - "πŸ“Š Reversal Check Result:\n", - " Should Trade: True\n", - " Reversal Score: 30%\n", - " Action: CAUTION\n", - " Lot Multiplier: 75%\n", - " Reason: Low reversal risk (30%), lot reduced to 75%\n", - "\n", - "πŸ” Signal Details:\n", - " rsi_divergence: βœ… No divergence\n", - " ema_slope_change: ⚠️ Slope weakening: -0.1010% -> -0.4427%\n", - " volume_spike: βœ… Volume: 0.4x average\n", - " candlestick: ⚠️ Bearish Engulfing: Strong reversal signal\n", - " break_of_structure: βœ… Structure intact\n", - "\n", - "============================================================\n", - "βœ… Reversal Detector Test Complete\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:35:18,013 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:35:28,040 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:35:38,065 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:35:48,079 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:35:54,233 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:36:54 CET)\" (scheduled at 2026-01-30 09:35:54.085516+01:00)\n", - "2026-01-30 09:35:54,233 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:36:54 CET)\" executed successfully\n", - "2026-01-30 09:35:58,110 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:35:58,259 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:36:58 CET)\" (scheduled at 2026-01-30 09:35:58.257297+01:00)\n", - "2026-01-30 09:35:58,261 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:36:58 CET)\" executed successfully\n", - "2026-01-30 09:36:01,020 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:37:01 CET)\" (scheduled at 2026-01-30 09:36:01.013912+01:00)\n", - "2026-01-30 09:36:01,020 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:37:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:36:08,139 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:36:18,153 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:36:28,187 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:36:38,216 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:36:48,244 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:36:54,086 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:37:54 CET)\" (scheduled at 2026-01-30 09:36:54.085516+01:00)\n", - "2026-01-30 09:36:54,090 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:37:54 CET)\" executed successfully\n", - "2026-01-30 09:36:58,280 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:36:58,808 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:37:58 CET)\" (scheduled at 2026-01-30 09:36:58.257297+01:00)\n", - "2026-01-30 09:36:58,809 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:37:58 CET)\" executed successfully\n", - "2026-01-30 09:37:01,074 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:38:01 CET)\" (scheduled at 2026-01-30 09:37:01.013912+01:00)\n", - "2026-01-30 09:37:01,076 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:38:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:37:01,731 - INFO - Running job \"Demo Tracker Sync (trigger: interval[0:05:00], next run at: 2026-01-30 09:42:01 CET)\" (scheduled at 2026-01-30 09:37:01.544620+01:00)\n", - "2026-01-30 09:37:01,842 - INFO - πŸ“Š Trade logged: πŸ”΄ #734745233 LONG XAUUSD | Profit: $-129.50\n", - "2026-01-30 09:37:01,844 - INFO - Job \"Demo Tracker Sync (trigger: interval[0:05:00], next run at: 2026-01-30 09:42:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "πŸ“Š Auto-synced #734745233: LONG XAUUSD | stop_loss | P/L: $-129.50\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:37:08,306 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:37:18,332 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:37:28,357 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:37:38,382 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:37:48,405 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:37:54,087 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:38:54 CET)\" (scheduled at 2026-01-30 09:37:54.085516+01:00)\n", - "2026-01-30 09:37:54,089 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:38:54 CET)\" executed successfully\n", - "2026-01-30 09:37:58,258 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:38:58 CET)\" (scheduled at 2026-01-30 09:37:58.257297+01:00)\n", - "2026-01-30 09:37:58,261 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:38:58 CET)\" executed successfully\n", - "2026-01-30 09:37:58,433 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:38:01,018 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:39:01 CET)\" (scheduled at 2026-01-30 09:38:01.013912+01:00)\n", - "2026-01-30 09:38:01,020 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:39:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:38:08,458 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:38:18,483 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:38:28,509 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:38:38,532 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:38:48,771 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:38:54,088 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:39:54 CET)\" (scheduled at 2026-01-30 09:38:54.085516+01:00)\n", - "2026-01-30 09:38:54,090 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:39:54 CET)\" executed successfully\n", - "2026-01-30 09:38:58,258 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:39:58 CET)\" (scheduled at 2026-01-30 09:38:58.257297+01:00)\n", - "2026-01-30 09:38:58,260 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:39:58 CET)\" executed successfully\n", - "2026-01-30 09:38:58,795 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:39:01,015 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:40:01 CET)\" (scheduled at 2026-01-30 09:39:01.013912+01:00)\n", - "2026-01-30 09:39:01,019 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:40:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:39:08,820 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:39:18,844 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:39:28,867 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:39:38,892 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:39:48,916 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:39:54,093 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:40:54 CET)\" (scheduled at 2026-01-30 09:39:54.085516+01:00)\n", - "2026-01-30 09:39:54,096 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:40:54 CET)\" executed successfully\n", - "2026-01-30 09:39:58,258 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:40:58 CET)\" (scheduled at 2026-01-30 09:39:58.257297+01:00)\n", - "2026-01-30 09:39:58,260 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:40:58 CET)\" executed successfully\n", - "2026-01-30 09:39:58,939 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:40:01,016 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:41:01 CET)\" (scheduled at 2026-01-30 09:40:01.013912+01:00)\n", - "2026-01-30 09:40:01,020 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:41:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:40:08,963 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:40:18,987 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:40:29,011 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:40:39,039 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:40:49,063 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:40:54,089 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:41:54 CET)\" (scheduled at 2026-01-30 09:40:54.085516+01:00)\n", - "2026-01-30 09:40:54,091 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:41:54 CET)\" executed successfully\n", - "2026-01-30 09:40:58,259 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:41:58 CET)\" (scheduled at 2026-01-30 09:40:58.257297+01:00)\n", - "2026-01-30 09:40:58,261 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:41:58 CET)\" executed successfully\n", - "2026-01-30 09:40:59,086 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:41:01,018 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:42:01 CET)\" (scheduled at 2026-01-30 09:41:01.013912+01:00)\n", - "2026-01-30 09:41:01,020 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:42:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:41:09,111 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:41:19,137 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:41:29,164 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:41:39,187 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:41:49,210 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:41:54,087 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:42:54 CET)\" (scheduled at 2026-01-30 09:41:54.085516+01:00)\n", - "2026-01-30 09:41:54,089 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:42:54 CET)\" executed successfully\n", - "2026-01-30 09:41:58,257 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:42:58 CET)\" (scheduled at 2026-01-30 09:41:58.257297+01:00)\n", - "2026-01-30 09:41:58,259 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:42:58 CET)\" executed successfully\n", - "2026-01-30 09:41:59,259 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:42:01,017 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:43:01 CET)\" (scheduled at 2026-01-30 09:42:01.013912+01:00)\n", - "2026-01-30 09:42:01,019 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:43:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:42:01,545 - INFO - Running job \"Demo Tracker Sync (trigger: interval[0:05:00], next run at: 2026-01-30 09:47:01 CET)\" (scheduled at 2026-01-30 09:42:01.544620+01:00)\n", - "2026-01-30 09:42:01,553 - INFO - Job \"Demo Tracker Sync (trigger: interval[0:05:00], next run at: 2026-01-30 09:47:01 CET)\" executed successfully\n", - "2026-01-30 09:42:09,291 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:42:19,314 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:42:29,336 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:42:39,359 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:42:49,382 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:42:54,087 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:43:54 CET)\" (scheduled at 2026-01-30 09:42:54.085516+01:00)\n", - "2026-01-30 09:42:54,088 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:43:54 CET)\" executed successfully\n", - "2026-01-30 09:42:58,258 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:43:58 CET)\" (scheduled at 2026-01-30 09:42:58.257297+01:00)\n", - "2026-01-30 09:42:58,260 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:43:58 CET)\" executed successfully\n", - "2026-01-30 09:42:59,407 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:43:01,015 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:44:01 CET)\" (scheduled at 2026-01-30 09:43:01.013912+01:00)\n", - "2026-01-30 09:43:01,018 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:44:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:43:09,429 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:43:19,454 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:43:29,478 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:43:39,502 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:43:49,527 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:43:54,087 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:44:54 CET)\" (scheduled at 2026-01-30 09:43:54.085516+01:00)\n", - "2026-01-30 09:43:54,089 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:44:54 CET)\" executed successfully\n", - "2026-01-30 09:43:58,258 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:44:58 CET)\" (scheduled at 2026-01-30 09:43:58.257297+01:00)\n", - "2026-01-30 09:43:58,260 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:44:58 CET)\" executed successfully\n", - "2026-01-30 09:43:59,551 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:44:01,066 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:45:01 CET)\" (scheduled at 2026-01-30 09:44:01.013912+01:00)\n", - "2026-01-30 09:44:01,068 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:45:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:44:09,573 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:44:19,597 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:44:29,620 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:44:39,643 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:44:49,667 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:44:54,103 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:45:54 CET)\" (scheduled at 2026-01-30 09:44:54.085516+01:00)\n", - "2026-01-30 09:44:54,105 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:45:54 CET)\" executed successfully\n", - "2026-01-30 09:44:58,257 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:45:58 CET)\" (scheduled at 2026-01-30 09:44:58.257297+01:00)\n", - "2026-01-30 09:44:58,259 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:45:58 CET)\" executed successfully\n", - "2026-01-30 09:44:59,692 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:45:01,014 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:46:01 CET)\" (scheduled at 2026-01-30 09:45:01.013912+01:00)\n", - "2026-01-30 09:45:01,018 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:46:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:45:09,715 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:45:19,739 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:45:29,761 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:45:39,787 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:45:49,812 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:45:54,102 - INFO - Running job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:46:54 CET)\" (scheduled at 2026-01-30 09:45:54.085516+01:00)\n", - "2026-01-30 09:45:54,104 - INFO - Job \"PositionMonitor.check_open_positions (trigger: interval[0:01:00], next run at: 2026-01-30 09:46:54 CET)\" executed successfully\n", - "2026-01-30 09:45:58,258 - INFO - Running job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:46:58 CET)\" (scheduled at 2026-01-30 09:45:58.257297+01:00)\n", - "2026-01-30 09:45:58,260 - INFO - Job \"create_enhanced_position_monitor..enhanced_position_monitor (trigger: interval[0:01:00], next run at: 2026-01-30 09:46:58 CET)\" executed successfully\n", - "2026-01-30 09:45:59,836 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:46:01,016 - INFO - Running job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:47:01 CET)\" (scheduled at 2026-01-30 09:46:01.013912+01:00)\n", - "2026-01-30 09:46:01,019 - INFO - Job \"Enhanced Adaptive Trading Check (trigger: interval[0:01:00], next run at: 2026-01-30 09:47:01 CET)\" executed successfully\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "β›” SESSION BLOCKED: LONDON\n", - " Reason: London blocked: 12.5% win-rate, -$10/trade\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2026-01-30 09:46:09,859 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:46:19,888 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n", - "2026-01-30 09:46:29,914 - INFO - HTTP Request: POST https://api.telegram.org/bot7783303065:AAHVVvwWGqmhJ2BVq8LqkLRSsicKy1CUsD8/getUpdates \"HTTP/1.1 200 OK\"\n" - ] - } - ], - "source": [ - "# ==========================================\n", - "# πŸ§ͺ REVERSAL DETECTOR TEST\n", - "# ==========================================\n", - "\n", - "print(\"πŸ§ͺ Testing Reversal Detector...\")\n", - "print(\"=\" * 60)\n", - "\n", - "# Test 1: Import prΓΌfen\n", - "try:\n", - " from reversal_integration import check_reversal_risk, get_reversal_status, REVERSAL_CONFIG\n", - " print(\"βœ… Import erfolgreich\")\n", - "except Exception as e:\n", - " print(f\"❌ Import fehlgeschlagen: {e}\")\n", - "\n", - "# Test 2: Status anzeigen\n", - "print(\"\\n\" + get_reversal_status())\n", - "\n", - "# Test 3: Mit echten Marktdaten testen\n", - "print(\"\\nπŸ” Testing with live market data...\")\n", - "\n", - "signal_info = extended_top_down_v2_adaptive(\"XAUUSD\")\n", - "\n", - "if signal_info:\n", - " print(f\"\\nπŸ“Š Signal Info:\")\n", - " print(f\" Entry Signal: {signal_info['entry_signal']}\")\n", - " print(f\" Standard Trend: {signal_info.get('standard_trend', 'N/A')}\")\n", - " print(f\" Confidence: {signal_info['confidence']}%\")\n", - " \n", - " # Reversal Check durchfΓΌhren\n", - " print(\"\\nπŸ”„ Running Reversal Check...\")\n", - " result = check_reversal_risk(signal_info, \"XAUUSD\")\n", - " \n", - " print(f\"\\nπŸ“Š Reversal Check Result:\")\n", - " print(f\" Should Trade: {result['should_trade']}\")\n", - " print(f\" Reversal Score: {result['reversal_score']}%\")\n", - " print(f\" Action: {result['action']}\")\n", - " print(f\" Lot Multiplier: {result['lot_multiplier']:.0%}\")\n", - " print(f\" Reason: {result['reason']}\")\n", - " \n", - " if 'signals' in result and result['signals']:\n", - " print(f\"\\nπŸ” Signal Details:\")\n", - " for signal_name, signal_data in result['signals'].items():\n", - " status = \"⚠️\" if signal_data.get('detected', False) else \"βœ…\"\n", - " print(f\" {signal_name}: {status} {signal_data.get('description', 'N/A')}\")\n", - "else:\n", - " print(\"❌ Could not get signal info\")\n", - "\n", - "print(\"\\n\" + \"=\" * 60)\n", - "print(\"βœ… Reversal Detector Test Complete\")" - ] - }, { "cell_type": "code", "execution_count": null, @@ -5035,4 +6610,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/loss_protection_manager.py b/loss_protection_manager.py new file mode 100644 index 0000000..41c4d19 --- /dev/null +++ b/loss_protection_manager.py @@ -0,0 +1,654 @@ +#!/usr/bin/env python3 +""" +πŸ›‘οΈ LOSS PROTECTION MANAGER +Umfassender Verlustschutz fΓΌr den Trading Bot + +FEATURES: +1. Daily Loss Limit - Stoppt Trading nach X% Tagesverlust +2. Consecutive Loss Breaker - Pausiert nach X Verlusten in Folge +3. Max Drawdown Circuit Breaker - Hard Stop bei kritischem Drawdown +4. News Filter - Vermeidet Trading bei High-Impact News + +VERWENDUNG: + from loss_protection_manager import LossProtectionManager + + lpm = LossProtectionManager() + + # Vor jedem Trade prΓΌfen: + allowed, reason, multiplier = lpm.check_trading_allowed() + + if not allowed: + print(f"Trading blocked: {reason}") + return None + + # Nach jedem Trade updaten: + lpm.record_trade(profit=-50.00, symbol="XAUUSD") +""" + +import json +import os +import logging +from datetime import datetime, timedelta +from typing import Dict, Tuple, List, Optional +import requests + +logger = logging.getLogger(__name__) + + +class LossProtectionManager: + """ + Comprehensive Loss Protection System + + Features: + - Daily loss limit with auto-reset at midnight + - Consecutive loss tracking with cooldown period + - Max drawdown circuit breaker + - Economic calendar news filter + """ + + def __init__(self, + # Daily Loss Limit + daily_loss_limit_pct: float = 2.0, + daily_loss_limit_dollars: float = 500.0, + + # Consecutive Loss Breaker + max_consecutive_losses: int = 3, + cooldown_minutes: int = 120, + + # Max Drawdown Circuit Breaker + max_drawdown_pct: float = 10.0, + drawdown_recovery_pct: float = 5.0, + + # News Filter + news_filter_enabled: bool = True, + news_buffer_minutes: int = 30, + block_high_impact: bool = True, + block_medium_impact: bool = False, + + # General + data_file: str = "loss_protection_state.json", + account_balance: float = 100000.0): + """ + Args: + daily_loss_limit_pct: Max daily loss as % of account (default: 2%) + daily_loss_limit_dollars: Max daily loss in dollars (default: $500) + max_consecutive_losses: Losses in a row before pause (default: 3) + cooldown_minutes: Pause duration after consecutive losses (default: 2h) + max_drawdown_pct: Circuit breaker threshold (default: 10%) + drawdown_recovery_pct: Recovery needed to resume (default: 5%) + news_filter_enabled: Enable news filtering (default: True) + news_buffer_minutes: Minutes before/after news to avoid (default: 30) + block_high_impact: Block during high-impact news (default: True) + block_medium_impact: Block during medium-impact news (default: False) + data_file: File for persistent state + account_balance: Account balance for % calculations + """ + # Daily Loss Settings + self.daily_loss_limit_pct = daily_loss_limit_pct + self.daily_loss_limit_dollars = daily_loss_limit_dollars + + # Consecutive Loss Settings + self.max_consecutive_losses = max_consecutive_losses + self.cooldown_minutes = cooldown_minutes + + # Drawdown Settings + self.max_drawdown_pct = max_drawdown_pct + self.drawdown_recovery_pct = drawdown_recovery_pct + + # News Settings + self.news_filter_enabled = news_filter_enabled + self.news_buffer_minutes = news_buffer_minutes + self.block_high_impact = block_high_impact + self.block_medium_impact = block_medium_impact + + # General + self.data_file = data_file + self.account_balance = account_balance + + # State + self.state = self._load_state() + self._check_daily_reset() + + # News cache + self.news_cache = [] + self.news_cache_time = None + + self._log_initialization() + + # ========================================== + # MAIN CHECK METHOD + # ========================================== + + def check_trading_allowed(self, mt5_account_info=None) -> Tuple[bool, str, float]: + """ + HauptprΓΌfung ob Trading erlaubt ist + + Args: + mt5_account_info: Optional MT5 account info for live balance + + Returns: + (allowed, reason, lot_multiplier) + - allowed: True wenn Trading erlaubt + - reason: ErklΓ€rung + - lot_multiplier: 1.0 = normal, 0.5 = reduziert, 0.0 = blockiert + """ + # Update account balance if provided + if mt5_account_info: + self.account_balance = mt5_account_info.balance + + # Check 1: Daily Loss Limit + daily_allowed, daily_reason = self._check_daily_loss_limit() + if not daily_allowed: + return False, f"πŸ›‘ DAILY LIMIT: {daily_reason}", 0.0 + + # Check 2: Consecutive Losses + consec_allowed, consec_reason, consec_mult = self._check_consecutive_losses() + if not consec_allowed: + return False, f"πŸ›‘ CONSECUTIVE LOSSES: {consec_reason}", 0.0 + + # Check 3: Max Drawdown Circuit Breaker + dd_allowed, dd_reason = self._check_drawdown_circuit_breaker() + if not dd_allowed: + return False, f"πŸ›‘ CIRCUIT BREAKER: {dd_reason}", 0.0 + + # Check 4: News Filter + news_allowed, news_reason, news_mult = self._check_news_filter() + if not news_allowed: + return False, f"πŸ›‘ NEWS FILTER: {news_reason}", 0.0 + + # All checks passed - calculate final multiplier + final_multiplier = min(consec_mult, news_mult) + + # Build status message + status_parts = [] + if self.state['daily_loss'] != 0: + status_parts.append(f"Daily: ${self.state['daily_loss']:.2f}") + if self.state['consecutive_losses'] > 0: + status_parts.append(f"Consec: {self.state['consecutive_losses']}") + + if status_parts: + reason = f"βœ… Trading allowed ({', '.join(status_parts)})" + else: + reason = "βœ… All protection checks passed" + + if final_multiplier < 1.0: + reason += f" | Lot: {final_multiplier:.0%}" + + return True, reason, final_multiplier + + # ========================================== + # INDIVIDUAL CHECKS + # ========================================== + + def _check_daily_loss_limit(self) -> Tuple[bool, str]: + """PrΓΌft Daily Loss Limit""" + self._check_daily_reset() + + daily_loss = abs(self.state['daily_loss']) + limit_dollars = self.daily_loss_limit_dollars + limit_pct = self.daily_loss_limit_pct + + # Calculate % loss + if self.account_balance > 0: + loss_pct = (daily_loss / self.account_balance) * 100 + else: + loss_pct = 0 + + # Check dollar limit + if daily_loss >= limit_dollars: + return False, f"${daily_loss:.2f} loss today (limit: ${limit_dollars:.2f})" + + # Check percentage limit + if loss_pct >= limit_pct: + return False, f"{loss_pct:.1f}% loss today (limit: {limit_pct:.1f}%)" + + return True, f"${daily_loss:.2f} / ${limit_dollars:.2f} ({loss_pct:.1f}%)" + + def _check_consecutive_losses(self) -> Tuple[bool, str, float]: + """PrΓΌft Consecutive Loss Breaker""" + consec = self.state['consecutive_losses'] + cooldown_until = self.state.get('cooldown_until') + + # Check if in cooldown + if cooldown_until: + cooldown_time = datetime.fromisoformat(cooldown_until) + if datetime.now() < cooldown_time: + remaining = (cooldown_time - datetime.now()).total_seconds() / 60 + return False, f"Cooldown active ({remaining:.0f} min remaining)", 0.0 + else: + # Cooldown expired, reset + self.state['cooldown_until'] = None + self.state['consecutive_losses'] = 0 + self._save_state() + + # Check consecutive losses + if consec >= self.max_consecutive_losses: + # Activate cooldown + cooldown_until = datetime.now() + timedelta(minutes=self.cooldown_minutes) + self.state['cooldown_until'] = cooldown_until.isoformat() + self._save_state() + return False, f"{consec} consecutive losses - {self.cooldown_minutes}min cooldown activated", 0.0 + + # Calculate multiplier based on streak + if consec == 0: + multiplier = 1.0 + elif consec == 1: + multiplier = 0.75 # Reduce after 1 loss + elif consec == 2: + multiplier = 0.5 # Reduce more after 2 losses + else: + multiplier = 0.25 # Minimal size + + return True, f"{consec}/{self.max_consecutive_losses} consecutive losses", multiplier + + def _check_drawdown_circuit_breaker(self) -> Tuple[bool, str]: + """PrΓΌft Max Drawdown Circuit Breaker""" + if self.state.get('circuit_breaker_active', False): + # Check if recovered enough + peak = self.state.get('peak_equity', self.account_balance) + current = self.account_balance + recovery_target = peak * (1 - (self.max_drawdown_pct - self.drawdown_recovery_pct) / 100) + + if current >= recovery_target: + # Recovered, deactivate circuit breaker + self.state['circuit_breaker_active'] = False + self._save_state() + return True, "Circuit breaker deactivated - recovered" + else: + recovery_needed = recovery_target - current + return False, f"Circuit breaker active - need ${recovery_needed:.2f} recovery" + + # Calculate current drawdown + peak = self.state.get('peak_equity', self.account_balance) + if self.account_balance > peak: + self.state['peak_equity'] = self.account_balance + peak = self.account_balance + self._save_state() + + if peak > 0: + drawdown_pct = ((peak - self.account_balance) / peak) * 100 + else: + drawdown_pct = 0 + + if drawdown_pct >= self.max_drawdown_pct: + # Activate circuit breaker + self.state['circuit_breaker_active'] = True + self._save_state() + return False, f"{drawdown_pct:.1f}% drawdown - circuit breaker ACTIVATED" + + return True, f"Drawdown: {drawdown_pct:.1f}% (limit: {self.max_drawdown_pct:.1f}%)" + + def _check_news_filter(self) -> Tuple[bool, str, float]: + """PrΓΌft News Filter""" + if not self.news_filter_enabled: + return True, "News filter disabled", 1.0 + + # Get upcoming news + news = self._get_upcoming_news() + + if not news: + return True, "No high-impact news nearby", 1.0 + + # Check for news within buffer period + now = datetime.now() + buffer = timedelta(minutes=self.news_buffer_minutes) + + for event in news: + event_time = event.get('time') + if event_time: + if isinstance(event_time, str): + try: + event_time = datetime.fromisoformat(event_time.replace('Z', '+00:00')) + except: + continue + + time_diff = abs((event_time - now).total_seconds() / 60) + + if time_diff <= self.news_buffer_minutes: + impact = event.get('impact', 'unknown') + title = event.get('title', 'Unknown Event') + + if impact == 'high' and self.block_high_impact: + return False, f"High-impact: {title} in {time_diff:.0f}min", 0.0 + elif impact == 'medium' and self.block_medium_impact: + return False, f"Medium-impact: {title} in {time_diff:.0f}min", 0.0 + elif impact == 'high': + # Don't block but reduce size + return True, f"Caution: {title} in {time_diff:.0f}min", 0.5 + + return True, "No concerning news", 1.0 + + def _get_upcoming_news(self) -> List[Dict]: + """Holt kommende News-Events (mit Caching)""" + # Use cache if recent (15 min) + if self.news_cache_time and (datetime.now() - self.news_cache_time).seconds < 900: + return self.news_cache + + # Try to fetch from economic calendar API + try: + # ForexFactory-style calendar (simplified) + # In production, use a proper economic calendar API + self.news_cache = self._fetch_economic_calendar() + self.news_cache_time = datetime.now() + return self.news_cache + except Exception as e: + logger.debug(f"Could not fetch news: {e}") + return [] + + def _fetch_economic_calendar(self) -> List[Dict]: + """ + Fetcht Economic Calendar Events + + In production sollte hier eine echte API verwendet werden: + - ForexFactory API + - Investing.com Calendar + - FXStreet Calendar + - etc. + """ + # Simplified: Return empty list or static high-impact events + # This is a placeholder - implement real API integration as needed + + # Example static high-impact events (USD-focused for Gold trading) + static_events = [ + # These would normally come from an API + # {"title": "FOMC Rate Decision", "time": "2026-01-30T19:00:00", "impact": "high", "currency": "USD"}, + # {"title": "Non-Farm Payrolls", "time": "2026-02-07T13:30:00", "impact": "high", "currency": "USD"}, + ] + + return static_events + + # ========================================== + # TRADE RECORDING + # ========================================== + + def record_trade(self, profit: float, symbol: str = "XAUUSD"): + """ + Zeichnet einen abgeschlossenen Trade auf + + Args: + profit: Gewinn/Verlust des Trades + symbol: Gehandeltes Symbol + """ + self._check_daily_reset() + + # Update daily P/L + self.state['daily_loss'] += profit if profit < 0 else 0 + self.state['daily_profit'] += profit if profit > 0 else 0 + self.state['daily_trades'] += 1 + + # Update consecutive losses + if profit < 0: + self.state['consecutive_losses'] += 1 + self.state['consecutive_wins'] = 0 + else: + self.state['consecutive_losses'] = 0 + self.state['consecutive_wins'] += 1 + + # Update peak equity tracking + self.account_balance += profit # Approximate update + if self.account_balance > self.state.get('peak_equity', 0): + self.state['peak_equity'] = self.account_balance + + # Log + logger.info(f"πŸ“Š Trade recorded: ${profit:+.2f} | Daily: ${self.state['daily_loss']:.2f} | Consec losses: {self.state['consecutive_losses']}") + + self._save_state() + + def reset_consecutive_losses(self): + """Setzt Consecutive Loss Counter zurΓΌck (z.B. nach manuellem Review)""" + self.state['consecutive_losses'] = 0 + self.state['cooldown_until'] = None + self._save_state() + logger.info("πŸ”„ Consecutive losses reset") + + def reset_daily_stats(self): + """Setzt Tagesstatistiken zurΓΌck""" + self.state['daily_loss'] = 0 + self.state['daily_profit'] = 0 + self.state['daily_trades'] = 0 + self.state['last_reset_date'] = datetime.now().date().isoformat() + self._save_state() + logger.info("πŸ”„ Daily stats reset") + + def deactivate_circuit_breaker(self): + """Deaktiviert Circuit Breaker manuell (Vorsicht!)""" + self.state['circuit_breaker_active'] = False + self._save_state() + logger.warning("⚠️ Circuit breaker manually deactivated!") + + # ========================================== + # STATUS & REPORTING + # ========================================== + + def get_status(self) -> Dict: + """Gibt vollstΓ€ndigen Status zurΓΌck""" + self._check_daily_reset() + + # Calculate daily P/L percentage + daily_pnl = self.state['daily_profit'] + self.state['daily_loss'] + daily_pnl_pct = (daily_pnl / self.account_balance * 100) if self.account_balance > 0 else 0 + + # Calculate drawdown + peak = self.state.get('peak_equity', self.account_balance) + drawdown_pct = ((peak - self.account_balance) / peak * 100) if peak > 0 else 0 + + return { + 'trading_allowed': self.check_trading_allowed()[0], + + # Daily Stats + 'daily_loss': self.state['daily_loss'], + 'daily_profit': self.state['daily_profit'], + 'daily_pnl': daily_pnl, + 'daily_pnl_pct': daily_pnl_pct, + 'daily_trades': self.state['daily_trades'], + 'daily_limit_pct': self.daily_loss_limit_pct, + 'daily_limit_dollars': self.daily_loss_limit_dollars, + + # Consecutive Losses + 'consecutive_losses': self.state['consecutive_losses'], + 'consecutive_wins': self.state['consecutive_wins'], + 'max_consecutive_losses': self.max_consecutive_losses, + 'cooldown_active': self.state.get('cooldown_until') is not None, + 'cooldown_until': self.state.get('cooldown_until'), + + # Drawdown + 'current_drawdown_pct': drawdown_pct, + 'max_drawdown_limit': self.max_drawdown_pct, + 'circuit_breaker_active': self.state.get('circuit_breaker_active', False), + 'peak_equity': peak, + 'current_equity': self.account_balance, + + # News + 'news_filter_enabled': self.news_filter_enabled, + 'upcoming_news': self._get_upcoming_news()[:3], # Top 3 + } + + def get_report(self) -> str: + """Generiert formatierten Status-Report""" + status = self.get_status() + + report = [] + report.append("") + report.append("=" * 60) + report.append("πŸ›‘οΈ LOSS PROTECTION STATUS") + report.append("=" * 60) + + # Overall Status + if status['trading_allowed']: + report.append(" Status: βœ… TRADING ALLOWED") + else: + report.append(" Status: πŸ›‘ TRADING BLOCKED") + + report.append("") + + # Daily Loss Section + report.append("πŸ“… DAILY LIMITS:") + daily_pct = abs(status['daily_loss']) / self.account_balance * 100 if self.account_balance > 0 else 0 + report.append(f" Loss Today: ${abs(status['daily_loss']):,.2f} ({daily_pct:.1f}%)") + report.append(f" Limit: ${status['daily_limit_dollars']:,.2f} ({status['daily_limit_pct']}%)") + report.append(f" Trades Today: {status['daily_trades']}") + + report.append("") + + # Consecutive Losses Section + report.append("πŸ”’ CONSECUTIVE LOSSES:") + report.append(f" Current Streak: {status['consecutive_losses']}/{status['max_consecutive_losses']}") + if status['cooldown_active']: + report.append(f" Cooldown Until: {status['cooldown_until']}") + else: + report.append(f" Cooldown: Not active") + + report.append("") + + # Drawdown Section + report.append("πŸ“‰ DRAWDOWN CIRCUIT BREAKER:") + report.append(f" Current DD: {status['current_drawdown_pct']:.1f}%") + report.append(f" Limit: {status['max_drawdown_limit']}%") + report.append(f" Peak Equity: ${status['peak_equity']:,.2f}") + report.append(f" Current Equity: ${status['current_equity']:,.2f}") + if status['circuit_breaker_active']: + report.append(f" Circuit Breaker: πŸ”΄ ACTIVE") + else: + report.append(f" Circuit Breaker: βœ… Inactive") + + report.append("") + + # News Section + report.append("πŸ“° NEWS FILTER:") + report.append(f" Enabled: {'Yes' if status['news_filter_enabled'] else 'No'}") + if status['upcoming_news']: + report.append(f" Upcoming Events: {len(status['upcoming_news'])}") + for event in status['upcoming_news'][:2]: + report.append(f" - {event.get('title', 'Unknown')} ({event.get('impact', '?')})") + else: + report.append(f" Upcoming Events: None in buffer period") + + report.append("") + report.append("=" * 60) + + return "\n".join(report) + + # ========================================== + # HELPER METHODS + # ========================================== + + def _check_daily_reset(self): + """PrΓΌft ob Tagesstatistiken zurΓΌckgesetzt werden mΓΌssen""" + today = datetime.now().date().isoformat() + last_reset = self.state.get('last_reset_date', '') + + if today != last_reset: + logger.info(f"πŸ“… New day detected - resetting daily stats") + self.state['daily_loss'] = 0 + self.state['daily_profit'] = 0 + self.state['daily_trades'] = 0 + self.state['last_reset_date'] = today + self._save_state() + + def _load_state(self) -> Dict: + """LΓ€dt State aus Datei""" + default_state = { + 'daily_loss': 0, + 'daily_profit': 0, + 'daily_trades': 0, + 'last_reset_date': datetime.now().date().isoformat(), + 'consecutive_losses': 0, + 'consecutive_wins': 0, + 'cooldown_until': None, + 'circuit_breaker_active': False, + 'peak_equity': self.account_balance, + } + + try: + if os.path.exists(self.data_file): + with open(self.data_file, 'r') as f: + loaded = json.load(f) + # Merge with defaults + for key in default_state: + if key not in loaded: + loaded[key] = default_state[key] + return loaded + except Exception as e: + logger.warning(f"Could not load state: {e}") + + return default_state + + def _save_state(self): + """Speichert State in Datei""" + try: + with open(self.data_file, 'w') as f: + json.dump(self.state, f, indent=2) + except Exception as e: + logger.error(f"Could not save state: {e}") + + def _log_initialization(self): + """Loggt Initialisierung""" + logger.info("=" * 60) + logger.info("πŸ›‘οΈ LOSS PROTECTION MANAGER INITIALIZED") + logger.info("=" * 60) + logger.info(f" Daily Loss Limit: {self.daily_loss_limit_pct}% / ${self.daily_loss_limit_dollars}") + logger.info(f" Max Consec. Losses: {self.max_consecutive_losses} (cooldown: {self.cooldown_minutes}min)") + logger.info(f" Max Drawdown: {self.max_drawdown_pct}%") + logger.info(f" News Filter: {'Enabled' if self.news_filter_enabled else 'Disabled'}") + logger.info(f" Account Balance: ${self.account_balance:,.2f}") + logger.info("=" * 60) + + +# ========================================== +# INTEGRATION HELPER +# ========================================== + +def create_loss_protection_check(lpm: LossProtectionManager): + """ + Erstellt eine Check-Funktion fΓΌr die Bot-Integration + + Usage: + loss_protection_check = create_loss_protection_check(lpm) + + # In trading wrapper: + allowed, reason, mult = loss_protection_check() + """ + def check(mt5_account_info=None): + return lpm.check_trading_allowed(mt5_account_info) + return check + + +# ========================================== +# STANDALONE TESTING +# ========================================== + +if __name__ == "__main__": + print("=" * 60) + print("πŸ›‘οΈ LOSS PROTECTION MANAGER TEST") + print("=" * 60) + + # Create manager + lpm = LossProtectionManager( + daily_loss_limit_pct=2.0, + daily_loss_limit_dollars=500.0, + max_consecutive_losses=3, + cooldown_minutes=120, + max_drawdown_pct=10.0, + news_filter_enabled=True, + account_balance=100000.0 + ) + + # Show initial status + print(lpm.get_report()) + + # Simulate some trades + print("\nπŸ§ͺ Simulating trades...") + + # Winning trade + lpm.record_trade(150.0, "XAUUSD") + allowed, reason, mult = lpm.check_trading_allowed() + print(f"After win: {reason} | Mult: {mult}") + + # Losing trades + for i in range(3): + lpm.record_trade(-100.0, "XAUUSD") + allowed, reason, mult = lpm.check_trading_allowed() + print(f"After loss {i+1}: {reason} | Mult: {mult}") + + # Show final status + print(lpm.get_report())