From c3010a67377928662ff6c26955b482a8f9244cd2 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Thu, 17 Jul 2025 02:25:52 +0300 Subject: [PATCH] dash fixes --- web/clean_dashboard.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/web/clean_dashboard.py b/web/clean_dashboard.py index 119917d..c680587 100644 --- a/web/clean_dashboard.py +++ b/web/clean_dashboard.py @@ -551,12 +551,29 @@ class CleanTradingDashboard: if self.update_batch_counter % self.update_batch_interval != 0: raise PreventUpdate - # Filter out HOLD signals before displaying + # Filter out HOLD signals and duplicate signals before displaying filtered_decisions = [] + seen_signals = set() # Track recent signals to avoid duplicates + for decision in self.recent_decisions: action = self._get_signal_attribute(decision, 'action', 'UNKNOWN') if action != 'HOLD': - filtered_decisions.append(decision) + # Create a unique key for this signal to avoid duplicates + timestamp = decision.get('timestamp', datetime.now()) + price = decision.get('price', 0) + confidence = decision.get('confidence', 0) + + # Only show signals that are significantly different or from different time periods + signal_key = f"{action}_{int(price)}_{int(confidence*100)}" + time_key = int(timestamp.timestamp() // 30) # Group by 30-second intervals + full_key = f"{signal_key}_{time_key}" + + if full_key not in seen_signals: + seen_signals.add(full_key) + filtered_decisions.append(decision) + + # Limit to last 10 signals to prevent UI clutter + filtered_decisions = filtered_decisions[-10:] # Log COB signal activity cob_signals = [d for d in filtered_decisions if d.get('type') == 'cob_liquidity_imbalance'] @@ -634,7 +651,7 @@ class CleanTradingDashboard: btc_snapshot = self._get_cob_snapshot('BTC/USDT') # Debug: Log COB data availability - OPTIMIZED: Less frequent logging - if n % 20 == 0: # Log every 20 seconds to reduce spam and improve performance + if n % 30 == 0: # Log every 30 seconds to reduce spam and improve performance logger.info(f"COB Update #{n % 100}: ETH snapshot: {eth_snapshot is not None}, BTC snapshot: {btc_snapshot is not None}") if hasattr(self, 'latest_cob_data'): eth_data_time = self.cob_last_update.get('ETH/USDT', 0) if hasattr(self, 'cob_last_update') else 0