gogo2/run_enhanced_scalping_dashboard.py
Dobromir Popov 392dbb4b61 wip
2025-05-26 23:04:52 +03:00

113 lines
4.2 KiB
Python

#!/usr/bin/env python3
"""
Enhanced Scalping Dashboard Launcher
Features:
- 1-second OHLCV bar charts instead of tick points
- 15-minute server-side tick cache for model training
- Enhanced volume visualization with buy/sell separation
- Ultra-low latency WebSocket streaming
- Real-time candle aggregation from tick data
"""
import sys
import logging
import argparse
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
from web.enhanced_scalping_dashboard import EnhancedScalpingDashboard
from core.data_provider import DataProvider
from core.enhanced_orchestrator import EnhancedTradingOrchestrator
def setup_logging(level: str = "INFO"):
"""Setup logging configuration"""
log_level = getattr(logging, level.upper(), logging.INFO)
logging.basicConfig(
level=log_level,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler('logs/enhanced_dashboard.log', mode='a')
]
)
# Reduce noise from external libraries
logging.getLogger('urllib3').setLevel(logging.WARNING)
logging.getLogger('requests').setLevel(logging.WARNING)
logging.getLogger('websockets').setLevel(logging.WARNING)
def main():
"""Main function to launch enhanced scalping dashboard"""
parser = argparse.ArgumentParser(description='Enhanced Scalping Dashboard with 1s Bars and 15min Cache')
parser.add_argument('--host', default='127.0.0.1', help='Host to bind to (default: 127.0.0.1)')
parser.add_argument('--port', type=int, default=8051, help='Port to bind to (default: 8051)')
parser.add_argument('--debug', action='store_true', help='Enable debug mode')
parser.add_argument('--log-level', default='INFO', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR'],
help='Logging level (default: INFO)')
args = parser.parse_args()
# Setup logging
setup_logging(args.log_level)
logger = logging.getLogger(__name__)
try:
logger.info("=" * 80)
logger.info("ENHANCED SCALPING DASHBOARD STARTUP")
logger.info("=" * 80)
logger.info("Features:")
logger.info(" - 1-second OHLCV bar charts (instead of tick points)")
logger.info(" - 15-minute server-side tick cache for model training")
logger.info(" - Enhanced volume visualization with buy/sell separation")
logger.info(" - Ultra-low latency WebSocket streaming")
logger.info(" - Real-time candle aggregation from tick data")
logger.info("=" * 80)
# Initialize core components
logger.info("Initializing data provider...")
data_provider = DataProvider()
logger.info("Initializing enhanced trading orchestrator...")
orchestrator = EnhancedTradingOrchestrator(data_provider)
# Create enhanced dashboard
logger.info("Creating enhanced scalping dashboard...")
dashboard = EnhancedScalpingDashboard(
data_provider=data_provider,
orchestrator=orchestrator
)
# Launch dashboard
logger.info(f"Launching dashboard at http://{args.host}:{args.port}")
logger.info("Dashboard Features:")
logger.info(" - Main chart: ETH/USDT 1s OHLCV bars with volume subplot")
logger.info(" - Secondary chart: BTC/USDT 1s bars")
logger.info(" - Volume analysis: Real-time volume comparison")
logger.info(" - Tick cache: 15-minute rolling window for model training")
logger.info(" - Trading session: $100 starting balance with P&L tracking")
logger.info(" - System performance: Real-time callback monitoring")
logger.info("=" * 80)
dashboard.run(
host=args.host,
port=args.port,
debug=args.debug
)
except KeyboardInterrupt:
logger.info("Dashboard stopped by user (Ctrl+C)")
except Exception as e:
logger.error(f"Error running enhanced dashboard: {e}")
logger.exception("Full traceback:")
sys.exit(1)
finally:
logger.info("Enhanced Scalping Dashboard shutdown complete")
if __name__ == "__main__":
main()