scalping dash also works initially

This commit is contained in:
Dobromir Popov
2025-05-26 16:02:40 +03:00
parent 39942386b1
commit c97177aa88
39 changed files with 7272 additions and 1076 deletions

View File

@ -1,133 +1,66 @@
#!/usr/bin/env python3
"""
Test Dashboard Startup
Simple script to test if the enhanced dashboard can start properly
Test Dashboard Startup - Debug the scalping dashboard startup issue
"""
import sys
import logging
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def test_imports():
"""Test all necessary imports"""
try:
print("✅ Testing imports...")
from core.config import get_config, setup_logging
print("✅ Core config import successful")
from core.data_provider import DataProvider
print("✅ Data provider import successful")
from core.enhanced_orchestrator import EnhancedTradingOrchestrator
print("✅ Enhanced orchestrator import successful")
from web.scalping_dashboard import create_scalping_dashboard
print("✅ Scalping dashboard import successful")
return True
except Exception as e:
print(f"❌ Import failed: {e}")
return False
# Setup logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def test_config():
"""Test config loading"""
def test_dashboard_startup():
"""Test dashboard startup with detailed error reporting"""
try:
print("Testing config...")
from core.config import get_config
config = get_config()
print(f"✅ Config loaded - symbols: {config.symbols}")
return True
except Exception as e:
print(f"❌ Config failed: {e}")
return False
def test_data_provider():
"""Test data provider initialization"""
try:
print("✅ Testing data provider...")
from core.data_provider import DataProvider
data_provider = DataProvider()
print("✅ Data provider initialized")
return True
except Exception as e:
print(f"❌ Data provider failed: {e}")
return False
def test_orchestrator():
"""Test orchestrator initialization"""
try:
print("✅ Testing orchestrator...")
from core.data_provider import DataProvider
from core.enhanced_orchestrator import EnhancedTradingOrchestrator
logger.info("Testing dashboard startup...")
data_provider = DataProvider()
orchestrator = EnhancedTradingOrchestrator(data_provider)
print("✅ Orchestrator initialized")
return True
except Exception as e:
print(f"❌ Orchestrator failed: {e}")
return False
def test_dashboard_creation():
"""Test dashboard creation"""
try:
print("✅ Testing dashboard creation...")
# Test imports
logger.info("Testing imports...")
from core.data_provider import DataProvider
from core.enhanced_orchestrator import EnhancedTradingOrchestrator
from web.scalping_dashboard import create_scalping_dashboard
logger.info("✅ All imports successful")
data_provider = DataProvider()
orchestrator = EnhancedTradingOrchestrator(data_provider)
dashboard = create_scalping_dashboard(data_provider, orchestrator)
print("✅ Dashboard created successfully")
return dashboard
# Test data provider
logger.info("Creating data provider...")
dp = DataProvider()
logger.info("✅ Data provider created")
# Test orchestrator
logger.info("Creating orchestrator...")
orch = EnhancedTradingOrchestrator(dp)
logger.info("✅ Orchestrator created")
# Test dashboard creation
logger.info("Creating dashboard...")
dashboard = create_scalping_dashboard(dp, orch)
logger.info("✅ Dashboard created successfully")
# Test data fetching
logger.info("Testing data fetching...")
test_data = dp.get_historical_data('ETH/USDT', '1m', limit=5)
if test_data is not None and not test_data.empty:
logger.info(f"✅ Data fetching works: {len(test_data)} candles")
else:
logger.warning("⚠️ No data returned from data provider")
# Start dashboard
logger.info("Starting dashboard on http://127.0.0.1:8051")
logger.info("Press Ctrl+C to stop")
dashboard.run(host='127.0.0.1', port=8051, debug=True)
except KeyboardInterrupt:
logger.info("Dashboard stopped by user")
except Exception as e:
print(f"❌ Dashboard creation failed: {e}")
return None
def main():
"""Run all tests"""
print("🔍 TESTING ENHANCED DASHBOARD STARTUP")
print("="*50)
# Test each component
tests = [
test_imports,
test_config,
test_data_provider,
test_orchestrator,
test_dashboard_creation
]
for test in tests:
if not test():
print(f"❌ FAILED: {test.__name__}")
return False
print()
print("✅ ALL TESTS PASSED!")
print("🚀 Dashboard should be able to start successfully")
# Optionally try to start the dashboard
response = input("\n🔥 Would you like to start the dashboard now? (y/n): ")
if response.lower() == 'y':
try:
dashboard = test_dashboard_creation()
if dashboard:
print("🚀 Starting dashboard on http://127.0.0.1:8051")
dashboard.run(host='127.0.0.1', port=8051, debug=False)
except KeyboardInterrupt:
print("\n👋 Dashboard stopped by user")
except Exception as e:
print(f"❌ Dashboard startup failed: {e}")
return True
logger.error(f"❌ Error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)
test_dashboard_startup()