dash interval updated

This commit is contained in:
Dobromir Popov
2025-06-24 19:12:12 +03:00
parent 97f7f54c30
commit 165b3be21a
2 changed files with 17 additions and 9 deletions

View File

@ -778,10 +778,10 @@ class TradingDashboard:
className="text-light mb-0 opacity-75 small")
], className="bg-dark p-2 mb-2"),
# Auto-refresh component - optimized for efficient updates
# Auto-refresh component - ultra-fast updates for real-time trading
dcc.Interval(
id='interval-component',
interval=10000, # Update every 10 seconds for efficiency
interval=1000, # Update every 1 second for maximum responsiveness
n_intervals=0
),
@ -1035,9 +1035,9 @@ class TradingDashboard:
update_start = time.time()
try:
# Smart update scheduling - different frequencies for different components
# Smart update scheduling - optimized for 1s responsiveness
is_price_update = True # Price updates every interval (1s)
is_chart_update = n_intervals % 5 == 0 # Chart updates every 5s
is_chart_update = True # Chart updates every 1s for real-time feel
is_heavy_update = n_intervals % 10 == 0 # Heavy operations every 10s
is_cleanup_update = n_intervals % 60 == 0 # Cleanup every 60s
@ -1143,12 +1143,12 @@ class TradingDashboard:
# MEXC status (simple)
mexc_status = "LIVE" if (self.trading_executor and self.trading_executor.trading_enabled and not self.trading_executor.simulation_mode) else "SIM"
# CHART OPTIMIZATION - Only update charts every 5 seconds
# CHART OPTIMIZATION - Real-time chart updates every 1 second
if is_chart_update:
try:
if hasattr(self, '_cached_chart_data_time'):
cache_time = self._cached_chart_data_time
if time.time() - cache_time < 20: # Use cached chart if < 20s old
if time.time() - cache_time < 5: # Use cached chart if < 5s old for faster updates
price_chart = getattr(self, '_cached_price_chart', None)
else:
price_chart = self._create_price_chart_optimized(symbol, current_price)
@ -1163,7 +1163,7 @@ class TradingDashboard:
price_chart = getattr(self, '_cached_price_chart',
self._create_empty_chart("Chart Error", "Chart temporarily unavailable"))
else:
# Use cached chart
# Use cached chart (should not happen since is_chart_update is always True now)
price_chart = getattr(self, '_cached_price_chart',
self._create_empty_chart("Loading", "Chart loading..."))