This commit is contained in:
Dobromir Popov
2025-10-22 17:48:44 +03:00
parent 68b91f37bd
commit f456b2747e
5 changed files with 127 additions and 7 deletions

View File

@@ -64,6 +64,50 @@ class HistoricalDataLoader:
return cached_data
try:
# Try unified storage first if available
if hasattr(self.data_provider, 'is_unified_storage_enabled') and \
self.data_provider.is_unified_storage_enabled():
try:
import asyncio
# Get data from unified storage
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
# If we have a specific time range, get historical data
if start_time or end_time:
target_time = end_time if end_time else start_time
inference_data = loop.run_until_complete(
self.data_provider.get_inference_data_unified(
symbol,
timestamp=target_time,
context_window_minutes=60
)
)
else:
# Get latest real-time data
inference_data = loop.run_until_complete(
self.data_provider.get_inference_data_unified(symbol)
)
# Extract the requested timeframe
df = inference_data.get_timeframe_data(timeframe)
if df is not None and not df.empty:
# Limit number of candles
if len(df) > limit:
df = df.tail(limit)
# Cache in memory
self.memory_cache[cache_key] = (df.copy(), datetime.now())
logger.info(f"Loaded {len(df)} candles from unified storage for {symbol} {timeframe}")
return df
except Exception as e:
logger.debug(f"Unified storage not available, falling back to cached data: {e}")
# Fallback to existing cached data method
# Use DataProvider's cached data if available
if hasattr(self.data_provider, 'cached_data'):
if symbol in self.data_provider.cached_data: