82 lines
3.0 KiB
Python
82 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for enhanced trading dashboard with WebSocket support
|
|
"""
|
|
|
|
import sys
|
|
import logging
|
|
from datetime import datetime
|
|
|
|
# Setup logging
|
|
logging.basicConfig(level=logging.INFO)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def test_dashboard():
|
|
"""Test the enhanced dashboard functionality"""
|
|
try:
|
|
print("="*60)
|
|
print("TESTING ENHANCED TRADING DASHBOARD")
|
|
print("="*60)
|
|
|
|
# Import dashboard
|
|
from web.dashboard import TradingDashboard, WEBSOCKET_AVAILABLE
|
|
|
|
print(f"✓ Dashboard module imported successfully")
|
|
print(f"✓ WebSocket support available: {WEBSOCKET_AVAILABLE}")
|
|
|
|
# Create dashboard instance
|
|
dashboard = TradingDashboard()
|
|
|
|
print(f"✓ Dashboard instance created")
|
|
print(f"✓ Tick cache capacity: {dashboard.tick_cache.maxlen} ticks (15 min)")
|
|
print(f"✓ 1s bars capacity: {dashboard.one_second_bars.maxlen} bars (15 min)")
|
|
print(f"✓ WebSocket streaming: {dashboard.is_streaming}")
|
|
print(f"✓ Min confidence threshold: {dashboard.min_confidence_threshold}")
|
|
print(f"✓ Signal cooldown: {dashboard.signal_cooldown}s")
|
|
|
|
# Test tick cache methods
|
|
tick_cache = dashboard.get_tick_cache_for_training(minutes=5)
|
|
print(f"✓ Tick cache method works: {len(tick_cache)} ticks")
|
|
|
|
# Test 1s bars method
|
|
bars_df = dashboard.get_one_second_bars(count=100)
|
|
print(f"✓ 1s bars method works: {len(bars_df)} bars")
|
|
|
|
# Test chart creation
|
|
try:
|
|
chart = dashboard._create_price_chart("ETH/USDT")
|
|
print(f"✓ Price chart creation works")
|
|
except Exception as e:
|
|
print(f"⚠ Price chart creation: {e}")
|
|
|
|
print("\n" + "="*60)
|
|
print("ENHANCED DASHBOARD FEATURES:")
|
|
print("="*60)
|
|
print("✓ Real-time WebSocket tick streaming (when websocket-client installed)")
|
|
print("✓ 1-second bar charts with volume")
|
|
print("✓ 15-minute tick cache for model training")
|
|
print("✓ Confidence-based signal execution")
|
|
print("✓ Clear signal vs execution distinction")
|
|
print("✓ Real-time unrealized P&L display")
|
|
print("✓ Compact layout with system status icon")
|
|
print("✓ Scalping-optimized signal generation")
|
|
|
|
print("\n" + "="*60)
|
|
print("TO START THE DASHBOARD:")
|
|
print("="*60)
|
|
print("1. Install WebSocket support: pip install websocket-client")
|
|
print("2. Run: python -c \"from web.dashboard import TradingDashboard; TradingDashboard().run()\"")
|
|
print("3. Open browser: http://127.0.0.1:8050")
|
|
print("="*60)
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error testing dashboard: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = test_dashboard()
|
|
sys.exit(0 if success else 1) |