stability
This commit is contained in:
@ -83,6 +83,13 @@ class PivotBounds:
|
||||
distances = [abs(current_price - r) for r in self.pivot_resistance_levels]
|
||||
return min(distances) / self.get_price_range()
|
||||
|
||||
@dataclass
|
||||
class SimplePivotLevel:
|
||||
"""Simple pivot level structure for fallback pivot detection"""
|
||||
swing_points: List[Any] = field(default_factory=list)
|
||||
support_levels: List[float] = field(default_factory=list)
|
||||
resistance_levels: List[float] = field(default_factory=list)
|
||||
|
||||
@dataclass
|
||||
class MarketTick:
|
||||
"""Standardized market tick data structure"""
|
||||
@ -127,6 +134,10 @@ class DataProvider:
|
||||
self.real_time_data = {} # {symbol: {timeframe: deque}}
|
||||
self.current_prices = {} # {symbol: float}
|
||||
|
||||
# Live price cache for low-latency price updates
|
||||
self.live_price_cache: Dict[str, Tuple[float, datetime]] = {}
|
||||
self.live_price_cache_ttl = timedelta(milliseconds=500)
|
||||
|
||||
# Initialize cached data structure
|
||||
for symbol in self.symbols:
|
||||
self.cached_data[symbol] = {}
|
||||
@ -1839,14 +1850,14 @@ class DataProvider:
|
||||
low_pivots = monthly_data[lows == rolling_min]['low'].tolist()
|
||||
pivot_lows.extend(low_pivots)
|
||||
|
||||
# Create mock level structure
|
||||
mock_level = type('MockLevel', (), {
|
||||
'swing_points': [],
|
||||
'support_levels': list(set(pivot_lows)),
|
||||
'resistance_levels': list(set(pivot_highs))
|
||||
})()
|
||||
# Create proper pivot level structure
|
||||
pivot_level = SimplePivotLevel(
|
||||
swing_points=[],
|
||||
support_levels=list(set(pivot_lows)),
|
||||
resistance_levels=list(set(pivot_highs))
|
||||
)
|
||||
|
||||
return {'level_0': mock_level}
|
||||
return {'level_0': pivot_level}
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in simple pivot detection: {e}")
|
||||
|
Reference in New Issue
Block a user