193 lines
7.7 KiB
Python
193 lines
7.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Run Ultra-Fast Scalping Dashboard (500x Leverage)
|
|
|
|
This script starts the custom scalping dashboard with:
|
|
- Full-width 1s ETH/USDT candlestick chart
|
|
- 3 small ETH charts: 1m, 1h, 1d
|
|
- 1 small BTC 1s chart
|
|
- Ultra-fast 100ms updates for scalping
|
|
- Real-time PnL tracking and logging
|
|
"""
|
|
|
|
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_market_connection(data_provider: DataProvider) -> bool:
|
|
"""
|
|
CRITICAL: Validate real market data connection
|
|
Returns False if connection fails or data seems synthetic
|
|
"""
|
|
try:
|
|
logger.info("🔍 VALIDATING REAL MARKET DATA CONNECTION...")
|
|
|
|
# Test primary trading symbols
|
|
test_symbols = ['ETH/USDT', 'BTC/USDT']
|
|
|
|
for symbol in test_symbols:
|
|
# Force fresh data fetch (no cache)
|
|
data = data_provider.get_historical_data(symbol, '1s', limit=100, refresh=True)
|
|
|
|
if data is None or data.empty:
|
|
logger.error(f"❌ CRITICAL: No real 1s data for {symbol}")
|
|
return False
|
|
|
|
# Validate data quality for scalping
|
|
if len(data) < 50:
|
|
logger.error(f"❌ CRITICAL: Insufficient real data for scalping {symbol}")
|
|
return False
|
|
|
|
# Check for realistic price variations
|
|
price_std = data['close'].std()
|
|
if price_std == 0:
|
|
logger.error(f"❌ CRITICAL: Static prices detected - possible synthetic data {symbol}")
|
|
return False
|
|
|
|
logger.info(f"✅ Real 1s data validated: {symbol} - {len(data)} candles, price_std: {price_std:.4f}")
|
|
|
|
logger.info("✅ REAL MARKET DATA CONNECTION VALIDATED FOR SCALPING")
|
|
return True
|
|
|
|
except Exception as e:
|
|
logger.error(f"❌ CRITICAL: Market data validation failed: {e}")
|
|
return False
|
|
|
|
class RealTradingEngine:
|
|
"""
|
|
Real trading engine that makes decisions based on live market analysis
|
|
NO SYNTHETIC DATA - Uses orchestrator for real market analysis
|
|
"""
|
|
|
|
def __init__(self, data_provider: DataProvider, orchestrator: EnhancedTradingOrchestrator):
|
|
self.data_provider = data_provider
|
|
self.orchestrator = orchestrator
|
|
self.running = False
|
|
self.trade_count = 0
|
|
|
|
def start(self):
|
|
"""Start real trading analysis"""
|
|
self.running = True
|
|
trading_thread = Thread(target=self._real_trading_loop, daemon=True)
|
|
trading_thread.start()
|
|
logger.info("🚀 REAL TRADING ENGINE STARTED - NO SYNTHETIC DATA")
|
|
|
|
def stop(self):
|
|
"""Stop trading analysis"""
|
|
self.running = False
|
|
logger.info("⏹️ Real trading engine stopped")
|
|
|
|
def _real_trading_loop(self):
|
|
"""
|
|
Real trading analysis loop using live market data ONLY
|
|
"""
|
|
logger.info("🔄 Starting REAL trading analysis loop...")
|
|
|
|
while self.running:
|
|
try:
|
|
# Analyze real market conditions for ETH/USDT and BTC/USDT
|
|
symbols = ['ETH/USDT', 'BTC/USDT']
|
|
|
|
for symbol in symbols:
|
|
# Get real-time market analysis from orchestrator
|
|
analysis = self.orchestrator.analyze_market_conditions(symbol)
|
|
|
|
if analysis is None:
|
|
logger.warning(f"⚠️ No real market analysis available for {symbol}")
|
|
continue
|
|
|
|
# Get real market data for decision making
|
|
current_data = self.data_provider.get_historical_data(
|
|
symbol, '1s', limit=20, refresh=True
|
|
)
|
|
|
|
if current_data is None or current_data.empty:
|
|
logger.warning(f"⚠️ No real current data for {symbol}")
|
|
continue
|
|
|
|
# Make trading decision based on REAL market analysis
|
|
decision = self.orchestrator.make_trading_decision(symbol)
|
|
|
|
if decision and decision.action in ['BUY', 'SELL']:
|
|
self.trade_count += 1
|
|
current_price = current_data['close'].iloc[-1]
|
|
|
|
logger.info(f"🔥 REAL TRADING DECISION #{self.trade_count}:")
|
|
logger.info(f" 📊 {decision.action} {symbol} @ ${current_price:.2f}")
|
|
logger.info(f" 📈 Confidence: {decision.confidence:.1%}")
|
|
logger.info(f" 💰 Based on REAL market analysis")
|
|
logger.info(f" 🕐 {datetime.now().strftime('%H:%M:%S')}")
|
|
|
|
# Wait between real analysis cycles (scalping frequency)
|
|
time.sleep(5) # 5-second analysis cycles for scalping
|
|
|
|
except Exception as e:
|
|
logger.error(f"❌ Error in real trading analysis: {e}")
|
|
time.sleep(10) # Longer wait on error
|
|
|
|
def main():
|
|
"""Main function for scalping dashboard with REAL DATA ONLY"""
|
|
logger.info("🚀 STARTING SCALPING DASHBOARD - 100% REAL MARKET DATA")
|
|
logger.info("🎯 Ultra-fast scalping with live market analysis")
|
|
logger.info("🚫 ZERO SYNTHETIC DATA - REAL DECISIONS ONLY")
|
|
|
|
try:
|
|
# Initialize data provider
|
|
data_provider = DataProvider()
|
|
|
|
# CRITICAL: Validate real market data connection
|
|
if not validate_real_market_connection(data_provider):
|
|
logger.error("❌ CRITICAL: Real market data validation FAILED")
|
|
logger.error("❌ Scalping dashboard will NOT start without verified real data")
|
|
logger.error("❌ NO SYNTHETIC DATA FALLBACK ALLOWED")
|
|
return 1
|
|
|
|
# Initialize orchestrator with validated real data
|
|
orchestrator = EnhancedTradingOrchestrator(data_provider)
|
|
|
|
# Test orchestrator with real data
|
|
logger.info("🔍 Testing orchestrator with real market data...")
|
|
test_analysis = orchestrator.analyze_market_conditions('ETH/USDT')
|
|
if test_analysis is None:
|
|
logger.error("❌ CRITICAL: Orchestrator failed to analyze real market data")
|
|
return 1
|
|
|
|
logger.info("✅ Orchestrator validated with real market data")
|
|
|
|
# Initialize real trading engine
|
|
trading_engine = RealTradingEngine(data_provider, orchestrator)
|
|
trading_engine.start()
|
|
|
|
logger.info("🎯 LAUNCHING SCALPING DASHBOARD WITH 100% REAL DATA")
|
|
logger.info("🔥 Real-time scalping decisions from live market analysis")
|
|
|
|
# Start the scalping dashboard with real data
|
|
run_scalping_dashboard(data_provider, orchestrator)
|
|
|
|
except KeyboardInterrupt:
|
|
logger.info("🛑 Scalping dashboard stopped by user")
|
|
return 0
|
|
except Exception as e:
|
|
logger.error(f"❌ CRITICAL ERROR: {e}")
|
|
logger.error("❌ Scalping dashboard stopped - NO SYNTHETIC DATA FALLBACK")
|
|
return 1
|
|
|
|
if __name__ == "__main__":
|
|
exit_code = main()
|
|
sys.exit(exit_code if exit_code else 0) |