models cleanup
This commit is contained in:
@ -278,52 +278,90 @@ def run_live_trading():
|
||||
raise
|
||||
|
||||
def run_web_dashboard():
|
||||
"""Run web dashboard with enhanced real-time data - NO SYNTHETIC DATA"""
|
||||
"""Run the web dashboard with real live data"""
|
||||
try:
|
||||
logger.info("Starting Web Dashboard Mode with REAL LIVE DATA...")
|
||||
|
||||
# Initialize with real data provider
|
||||
# Initialize core components with enhanced RL support
|
||||
from core.tick_aggregator import RealTimeTickAggregator
|
||||
from core.data_provider import DataProvider
|
||||
from core.enhanced_orchestrator import EnhancedTradingOrchestrator # Use enhanced version
|
||||
from core.trading_executor import TradingExecutor
|
||||
|
||||
# Create tick aggregator for real-time data - fix parameter name
|
||||
tick_aggregator = RealTimeTickAggregator(
|
||||
symbols=['ETHUSDC', 'BTCUSDT', 'MXUSDT'],
|
||||
tick_buffer_size=10000 # Changed from buffer_size to tick_buffer_size
|
||||
)
|
||||
|
||||
# Create data provider
|
||||
data_provider = DataProvider()
|
||||
|
||||
# Verify we have real data connection
|
||||
# Verify data connection with real data
|
||||
logger.info("[DATA] Verifying REAL data connection...")
|
||||
test_data = data_provider.get_historical_data('ETH/USDT', '1m', limit=10, refresh=True)
|
||||
if test_data is None or test_data.empty:
|
||||
logger.warning("⚠️ No fresh data available - trying cached data...")
|
||||
test_data = data_provider.get_historical_data('ETH/USDT', '1m', limit=10, refresh=False)
|
||||
|
||||
if test_data is None or test_data.empty:
|
||||
logger.warning("⚠️ No data available - starting dashboard with demo mode...")
|
||||
else:
|
||||
symbol = config.get('symbols', ['ETH/USDT'])[0]
|
||||
test_df = data_provider.get_historical_data(symbol, '1m', limit=10)
|
||||
if test_df is not None and len(test_df) > 0:
|
||||
logger.info("[SUCCESS] Data connection verified")
|
||||
logger.info(f"[SUCCESS] Fetched {len(test_data)} candles for validation")
|
||||
logger.info(f"[SUCCESS] Fetched {len(test_df)} candles for validation")
|
||||
else:
|
||||
logger.error("[ERROR] Data connection failed - no real data available")
|
||||
return
|
||||
|
||||
# Initialize orchestrator with real data only
|
||||
orchestrator = TradingOrchestrator(data_provider)
|
||||
# Load model registry
|
||||
model_registry = get_model_registry()
|
||||
|
||||
# Start dashboard - use the correct import
|
||||
# Create ENHANCED trading orchestrator for RL training
|
||||
orchestrator = EnhancedTradingOrchestrator(
|
||||
data_provider=data_provider,
|
||||
symbols=config.get('symbols', ['ETH/USDT']),
|
||||
enhanced_rl_training=True, # Enable enhanced RL
|
||||
model_registry=model_registry
|
||||
)
|
||||
logger.info("Enhanced RL Trading Orchestrator initialized")
|
||||
|
||||
# Create trading executor (handles MEXC integration)
|
||||
trading_executor = TradingExecutor()
|
||||
|
||||
# Import and create enhanced dashboard
|
||||
from web.dashboard import TradingDashboard
|
||||
dashboard = TradingDashboard(data_provider, orchestrator)
|
||||
dashboard = TradingDashboard(
|
||||
data_provider=data_provider,
|
||||
orchestrator=orchestrator, # Enhanced orchestrator
|
||||
trading_executor=trading_executor
|
||||
)
|
||||
|
||||
logger.info("[LAUNCH] LAUNCHING DASHBOARD")
|
||||
logger.info(f"[ACCESS] Access at: http://127.0.0.1:8050")
|
||||
# Start the dashboard
|
||||
port = config.get('web', {}).get('port', 8050)
|
||||
host = config.get('web', {}).get('host', '127.0.0.1')
|
||||
|
||||
# Run the dashboard
|
||||
dashboard.run(host='127.0.0.1', port=8050, debug=False)
|
||||
logger.info(f"TRADING: Starting Live Scalping Dashboard at http://{host}:{port}")
|
||||
logger.info("Enhanced RL Training: ENABLED")
|
||||
logger.info("Real Market Data: ENABLED")
|
||||
logger.info("MEXC Integration: ENABLED")
|
||||
|
||||
dashboard.run(host=host, port=port, debug=False)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in web dashboard: {e}")
|
||||
logger.error("Dashboard stopped - trying fallback mode")
|
||||
# Try a simpler fallback
|
||||
|
||||
try:
|
||||
# Fallback to basic dashboard function - use working import
|
||||
from web.dashboard import TradingDashboard
|
||||
from core.data_provider import DataProvider
|
||||
|
||||
# Create minimal dashboard
|
||||
data_provider = DataProvider()
|
||||
orchestrator = TradingOrchestrator(data_provider)
|
||||
dashboard = TradingDashboard(data_provider, orchestrator)
|
||||
dashboard = TradingDashboard(data_provider)
|
||||
logger.info("Using fallback dashboard")
|
||||
dashboard.run(host='127.0.0.1', port=8050, debug=False)
|
||||
except Exception as fallback_error:
|
||||
logger.error(f"Fallback dashboard also failed: {fallback_error}")
|
||||
raise
|
||||
logger.error(f"Fatal error: {e}")
|
||||
import traceback
|
||||
logger.error("Traceback (most recent call last):")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
async def main():
|
||||
"""Main entry point with clean mode selection"""
|
||||
|
Reference in New Issue
Block a user