#!/usr/bin/env python3 """ šŸ” Diagnose: Why No Trades Are Being Executed Checks all possible blocking reasons """ import sqlite3 from datetime import datetime, timedelta DB_PATH = "trading_bot.db" def diagnose_no_trades(): """Comprehensive diagnosis of why no trades""" print("=" * 70) print("šŸ” DIAGNOSE: WHY NO TRADES?") print("=" * 70) problems_found = [] # 1. Check Database print("\n1ļøāƒ£ CHECKING DATABASE...") try: conn = sqlite3.connect(DB_PATH) cursor = conn.cursor() # Consecutive losses cursor.execute(""" SELECT net_profit FROM trades WHERE status = 'closed' ORDER BY exit_time DESC LIMIT 20 """) trades = cursor.fetchall() consecutive_losses = 0 for trade in trades: if trade[0] < 0: consecutive_losses += 1 else: break print(f" Consecutive Losses: {consecutive_losses}") if consecutive_losses >= 5: problems_found.append(f"🚨 DRAWDOWN PROTECTION: {consecutive_losses} consecutive losses (limit: 5)") print(f" 🚨 BLOCKED: {consecutive_losses} ≄ 5") print(" šŸ’” Solution: Wait 24h cooldown OR run reset_consecutive_losses.py") else: print(f" āœ… OK: {consecutive_losses} < 5") # Check recent trades cursor.execute(""" SELECT COUNT(*) FROM trades WHERE entry_time >= datetime('now', '-1 day') """) recent_trades = cursor.fetchone()[0] print(f" Recent Trades (24h): {recent_trades}") # Check open positions cursor.execute(""" SELECT COUNT(*) FROM trades WHERE status = 'open' """) open_positions = cursor.fetchone()[0] print(f" Open Positions: {open_positions}") conn.close() except Exception as e: print(f" āŒ Database Error: {e}") problems_found.append("āŒ Database connection issue") # 2. Check Time/Session print("\n2ļøāƒ£ CHECKING TRADING SESSION...") now = datetime.utcnow() hour = now.hour # NY Session: 13:00-22:00 UTC # Asian Session: 23:00-08:00 UTC in_ny_session = 13 <= hour < 22 in_asian_session = hour >= 23 or hour < 8 print(f" Current Time (UTC): {now.strftime('%H:%M:%S')}") print(f" NY Session (13:00-22:00): {'āœ… ACTIVE' if in_ny_session else 'āŒ INACTIVE'}") print(f" Asian Session (23:00-08:00): {'āœ… ACTIVE' if in_asian_session else 'āŒ INACTIVE'}") if not in_ny_session and not in_asian_session: problems_found.append("ā° OUTSIDE TRADING SESSIONS (London blocked)") print(" 🚨 London Session is BLOCKED (break-even performance)") print(" šŸ’” Wait for NY (13:00 UTC) or Asian (23:00 UTC) session") else: print(" āœ… Currently in active trading session") # 3. Possible Ranging Market print("\n3ļøāƒ£ POSSIBLE BLOCKING REASONS...") print(" šŸ“Š Ranging Filter:") print(" If ADX < 25 → Trades are BLOCKED") print(" This is EXPECTED and PROTECTS you!") print(" šŸ’” Run show_current_regime() in notebook to check") print("\n šŸ“‰ Low Confidence:") print(" If confidence < 70% → Trade might be skipped") print(" šŸ’” Check confidence in signal") print("\n šŸ’° Risk Limits:") print(" If ATR too small → Trade skipped") print(" If position size < minimum → Trade skipped") print("\n šŸ”’ Max Positions:") print(" If already 1 position open → No new trades") print(f" Current open: {open_positions}") # 4. Summary print("\n" + "=" * 70) print("šŸ“‹ DIAGNOSIS SUMMARY") print("=" * 70) if problems_found: print("\n🚨 PROBLEMS FOUND:") for i, problem in enumerate(problems_found, 1): print(f" {i}. {problem}") else: print("\nāœ… NO BLOCKING ISSUES FOUND") print("\nšŸ’” MOST LIKELY REASONS:") print(" 1. šŸ›‘ Ranging Market (ADX < 25)") print(" → This is GOOD! Filter is protecting you") print(" → Check with: show_current_regime()") print("\n 2. šŸ“‰ Low Confidence Signal") print(" → Signal quality below threshold") print(" → This is GOOD! Only high-quality trades") print("\n 3. ā° Waiting for Better Entry") print(" → Bot is patient, waits for optimal conditions") print(" → This is GOOD! Quality over quantity") # 5. Action Items print("\n" + "=" * 70) print("šŸŽÆ ACTION ITEMS") print("=" * 70) print("\n1. Check Current Market Regime:") print(" In Jupyter Notebook run:") print(" → show_current_regime()") print("\n2. Check if Scheduler is Running:") print(" In Jupyter Notebook run:") print(" → scheduler.get_jobs()") print(" → Should show 5-6 active jobs") print("\n3. Check Last Trading Check:") print(" Look for these messages in notebook output:") print(" → 'šŸ›‘ TRADE BLOCKIERT: Ranging Market!' (expected)") print(" → 'āœ… REGIME CHECK PASSED: TRENDING' (good for trading)") print("\n4. Verify Ranging Filter is Active:") print(" In Jupyter Notebook run:") print(" → print(execute_trade_v2_adaptive)") print(" → Should show: 'execute_trade_v2_adaptive_with_ranging_filter'") print("\n" + "=" * 70) print("šŸ’” REMEMBER: No trades might be GOOD!") print("=" * 70) print("\nThe Ranging Filter BLOCKS unprofitable ranging markets.") print("This is PROTECTING you from losses!") print("\nāœ… Patience = Profitability") print("āœ… Quality trades > Quantity of trades") print("āœ… Wait for ADX > 25 (trending market)") print("\n") if __name__ == "__main__": diagnose_no_trades()