#!/usr/bin/env python3 """ Run Enhanced Trading Dashboard This script starts the web dashboard with the enhanced trading system for real-time monitoring and visualization. """ import asyncio import logging import sys import time from datetime import datetime from pathlib import Path from threading import Thread # Add project root to path project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) from core.config import get_config, setup_logging from core.data_provider import DataProvider from core.enhanced_orchestrator import EnhancedTradingOrchestrator from web.scalping_dashboard import run_scalping_dashboard # Setup logging setup_logging() logger = logging.getLogger(__name__) def validate_real_data_connection(data_provider: DataProvider) -> bool: """ CRITICAL: Validate that we have a real data connection Returns False if any synthetic data is detected or connection fails """ try: logger.info("🔍 VALIDATING REAL MARKET DATA CONNECTION...") # Test multiple symbols and timeframes test_symbols = ['ETH/USDT', 'BTC/USDT'] test_timeframes = ['1m', '5m'] for symbol in test_symbols: for timeframe in test_timeframes: # Force fresh data fetch (no cache) data = data_provider.get_historical_data(symbol, timeframe, limit=50, refresh=True) if data is None or data.empty: logger.error(f"❌ CRITICAL: No real data for {symbol} {timeframe}") return False # Validate data authenticity if len(data) < 10: logger.error(f"❌ CRITICAL: Insufficient real data for {symbol} {timeframe}") return False # Check for realistic price ranges (basic sanity check) prices = data['close'].values if 'ETH' in symbol and (prices.min() < 100 or prices.max() > 10000): logger.error(f"❌ CRITICAL: Unrealistic ETH prices detected - possible synthetic data") return False elif 'BTC' in symbol and (prices.min() < 10000 or prices.max() > 200000): logger.error(f"❌ CRITICAL: Unrealistic BTC prices detected - possible synthetic data") return False logger.info(f"✅ Real data validated: {symbol} {timeframe} - {len(data)} candles") logger.info("✅ ALL REAL MARKET DATA CONNECTIONS VALIDATED") return True except Exception as e: logger.error(f"❌ CRITICAL: Data validation failed: {e}") return False def main(): """Enhanced dashboard with REAL MARKET DATA ONLY""" logger.info("🚀 STARTING ENHANCED DASHBOARD - 100% REAL MARKET DATA") try: # Initialize data provider data_provider = DataProvider() # CRITICAL: Validate real data connection if not validate_real_data_connection(data_provider): logger.error("❌ CRITICAL: Real data validation FAILED") logger.error("❌ Dashboard will NOT start without verified real market data") logger.error("❌ NO SYNTHETIC DATA FALLBACK ALLOWED") return 1 # Initialize orchestrator with validated real data orchestrator = EnhancedTradingOrchestrator(data_provider) # Final check: Ensure orchestrator has real data logger.info("🔍 Final validation: Testing orchestrator with real data...") try: # Test orchestrator analysis with real data analysis = orchestrator.analyze_market_conditions('ETH/USDT') if analysis is None: logger.error("❌ CRITICAL: Orchestrator analysis failed - no real data") return 1 logger.info("✅ Orchestrator validated with real market data") except Exception as e: logger.error(f"❌ CRITICAL: Orchestrator validation failed: {e}") return 1 logger.info("🎯 LAUNCHING DASHBOARD WITH 100% REAL MARKET DATA") logger.info("🚫 ZERO SYNTHETIC DATA - REAL TRADING DECISIONS ONLY") # Start the dashboard with real data only run_scalping_dashboard(data_provider, orchestrator) except Exception as e: logger.error(f"❌ CRITICAL ERROR: {e}") logger.error("❌ Dashboard stopped - NO SYNTHETIC DATA FALLBACK") return 1 if __name__ == "__main__": exit_code = main() sys.exit(exit_code if exit_code else 0)