improve stream
This commit is contained in:
@@ -195,6 +195,9 @@ class TradingOrchestrator:
|
||||
|
||||
# Initialize and start data stream monitor (single source of truth)
|
||||
self._initialize_data_stream_monitor()
|
||||
|
||||
# Load historical data for models and RL training
|
||||
self._load_historical_data_for_models()
|
||||
|
||||
def _initialize_ml_models(self):
|
||||
"""Initialize ML models for enhanced trading"""
|
||||
@@ -2315,6 +2318,58 @@ class TradingOrchestrator:
|
||||
logger.error(f"Error getting COB data: {e}")
|
||||
return []
|
||||
|
||||
def _load_historical_data_for_models(self):
|
||||
"""Load 300 historical candles for all required timeframes and symbols for model training"""
|
||||
logger.info("Loading 300 historical candles for model training and RL context...")
|
||||
|
||||
try:
|
||||
# Required data for models:
|
||||
# ETH/USDT: 1m, 1h, 1d (300 candles each)
|
||||
# BTC/USDT: 1m (300 candles)
|
||||
|
||||
symbols_timeframes = [
|
||||
('ETH/USDT', '1m'),
|
||||
('ETH/USDT', '1h'),
|
||||
('ETH/USDT', '1d'),
|
||||
('BTC/USDT', '1m')
|
||||
]
|
||||
|
||||
loaded_data = {}
|
||||
total_candles = 0
|
||||
|
||||
for symbol, timeframe in symbols_timeframes:
|
||||
try:
|
||||
logger.info(f"Loading {symbol} {timeframe} historical data...")
|
||||
df = self.data_provider.get_historical_data(symbol, timeframe, limit=300)
|
||||
|
||||
if df is not None and not df.empty:
|
||||
loaded_data[f"{symbol}_{timeframe}"] = df
|
||||
total_candles += len(df)
|
||||
logger.info(f"✅ Loaded {len(df)} {timeframe} candles for {symbol}")
|
||||
|
||||
# Store in data provider's historical cache for quick access
|
||||
cache_key = f"{symbol}_{timeframe}_300"
|
||||
if not hasattr(self.data_provider, 'model_data_cache'):
|
||||
self.data_provider.model_data_cache = {}
|
||||
self.data_provider.model_data_cache[cache_key] = df
|
||||
|
||||
else:
|
||||
logger.warning(f"❌ No {timeframe} data available for {symbol}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading {symbol} {timeframe} data: {e}")
|
||||
|
||||
# Initialize model context data
|
||||
if hasattr(self, 'extrema_trainer') and self.extrema_trainer:
|
||||
logger.info("Initializing ExtremaTrainer with historical context...")
|
||||
self.extrema_trainer.initialize_context_data()
|
||||
|
||||
logger.info(f"🎯 Historical data loading complete: {total_candles} total candles loaded")
|
||||
logger.info(f"📊 Available datasets: {list(loaded_data.keys())}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in historical data loading: {e}")
|
||||
|
||||
def get_ohlcv_data(self, symbol: str, timeframe: str, limit: int = 300) -> List:
|
||||
"""Get OHLCV data for a symbol with specified timeframe and limit."""
|
||||
try:
|
||||
|
Reference in New Issue
Block a user