133 lines
4.1 KiB
Python
133 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test Dashboard Startup
|
|
Simple script to test if the enhanced dashboard can start properly
|
|
"""
|
|
|
|
import sys
|
|
import logging
|
|
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
|
|
|
|
def test_config():
|
|
"""Test config loading"""
|
|
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
|
|
|
|
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...")
|
|
from core.data_provider import DataProvider
|
|
from core.enhanced_orchestrator import EnhancedTradingOrchestrator
|
|
from web.scalping_dashboard import create_scalping_dashboard
|
|
|
|
data_provider = DataProvider()
|
|
orchestrator = EnhancedTradingOrchestrator(data_provider)
|
|
dashboard = create_scalping_dashboard(data_provider, orchestrator)
|
|
print("✅ Dashboard created successfully")
|
|
return dashboard
|
|
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
|
|
|
|
if __name__ == "__main__":
|
|
success = main()
|
|
sys.exit(0 if success else 1) |