added coin API WS implementation
This commit is contained in:
@ -1379,19 +1379,38 @@ class CleanTradingDashboard:
|
||||
eth_recent = _recent_ticks('ETH/USDT')
|
||||
btc_recent = _recent_ticks('BTC/USDT')
|
||||
|
||||
# Include per-exchange stats when available
|
||||
exchange_stats_eth = None
|
||||
exchange_stats_btc = None
|
||||
if hasattr(self.data_provider, 'cob_integration') and self.data_provider.cob_integration:
|
||||
try:
|
||||
snaps = self.data_provider.cob_integration.exchange_order_books
|
||||
if 'ETH/USDT' in snaps:
|
||||
exchange_stats_eth = {ex: {
|
||||
'bids': len(data.get('bids', {})),
|
||||
'asks': len(data.get('asks', {}))
|
||||
} for ex, data in snaps['ETH/USDT'].items() if isinstance(data, dict)}
|
||||
if 'BTC/USDT' in snaps:
|
||||
exchange_stats_btc = {ex: {
|
||||
'bids': len(data.get('bids', {})),
|
||||
'asks': len(data.get('asks', {}))
|
||||
} for ex, data in snaps['BTC/USDT'].items() if isinstance(data, dict)}
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
eth_components = self.component_manager.format_cob_data(
|
||||
eth_snapshot,
|
||||
'ETH/USDT',
|
||||
eth_imbalance_stats,
|
||||
cob_mode,
|
||||
update_info={'update_rate': eth_rate, 'aggregated_1s': eth_agg_1s[-5:], 'recent_ticks': eth_recent}
|
||||
update_info={'update_rate': eth_rate, 'aggregated_1s': eth_agg_1s[-5:], 'recent_ticks': eth_recent, 'exchanges': exchange_stats_eth}
|
||||
)
|
||||
btc_components = self.component_manager.format_cob_data(
|
||||
btc_snapshot,
|
||||
'BTC/USDT',
|
||||
btc_imbalance_stats,
|
||||
cob_mode,
|
||||
update_info={'update_rate': btc_rate, 'aggregated_1s': btc_agg_1s[-5:], 'recent_ticks': btc_recent}
|
||||
update_info={'update_rate': btc_rate, 'aggregated_1s': btc_agg_1s[-5:], 'recent_ticks': btc_recent, 'exchanges': exchange_stats_btc}
|
||||
)
|
||||
|
||||
return eth_components, btc_components
|
||||
@ -7089,7 +7108,7 @@ class CleanTradingDashboard:
|
||||
"""Initialize enhanced training system for model predictions"""
|
||||
try:
|
||||
# Try to import and initialize enhanced training system
|
||||
from enhanced_realtime_training import EnhancedRealtimeTrainingSystem
|
||||
from enhanced_realtime_training import EnhancedRealtimeTrainingSystem # Optional
|
||||
|
||||
self.training_system = EnhancedRealtimeTrainingSystem(
|
||||
orchestrator=self.orchestrator,
|
||||
@ -7106,7 +7125,7 @@ class CleanTradingDashboard:
|
||||
logger.debug("Enhanced training system initialized for model predictions")
|
||||
|
||||
except ImportError:
|
||||
logger.warning("Enhanced training system not available - using mock predictions")
|
||||
logger.warning("Enhanced training system not available - predictions disabled for this module")
|
||||
self.training_system = None
|
||||
except Exception as e:
|
||||
logger.error(f"Error initializing enhanced training system: {e}")
|
||||
|
@ -356,7 +356,8 @@ class COBDashboardServer:
|
||||
if mid_price <= 0:
|
||||
return
|
||||
|
||||
now = datetime.now()
|
||||
from datetime import timezone
|
||||
now = datetime.now(timezone.utc)
|
||||
current_second = now.replace(microsecond=0)
|
||||
|
||||
# Get or create current candle
|
||||
@ -377,7 +378,7 @@ class COBDashboardServer:
|
||||
if current_second > current_candle['timestamp']:
|
||||
# Close previous candle
|
||||
finished_candle = {
|
||||
'timestamp': current_candle['timestamp'].isoformat(),
|
||||
'timestamp': current_candle['timestamp'].isoformat(), # UTC ISO8601
|
||||
'open': current_candle['open'],
|
||||
'high': current_candle['high'],
|
||||
'low': current_candle['low'],
|
||||
|
@ -377,8 +377,21 @@ class DashboardComponentManager:
|
||||
overview_panel
|
||||
])
|
||||
|
||||
# --- Right Panel: Compact Ladder ---
|
||||
# --- Right Panel: Compact Ladder with optional exchange stats ---
|
||||
exchange_stats = (update_info or {}).get('exchanges') if isinstance(update_info, dict) else None
|
||||
ladder_panel = self._create_cob_ladder_panel(bids, asks, mid_price, symbol)
|
||||
if exchange_stats:
|
||||
# Render a tiny exchange contribution summary above ladder
|
||||
try:
|
||||
rows = []
|
||||
for ex, stats_ex in exchange_stats.items():
|
||||
rows.append(html.Small(f"{ex}: {stats_ex.get('bids',0)}/{stats_ex.get('asks',0)}", className="text-muted me-2"))
|
||||
ladder_panel = html.Div([
|
||||
html.Div(rows, className="mb-1"),
|
||||
ladder_panel
|
||||
])
|
||||
except Exception:
|
||||
pass
|
||||
# Append small extras line from aggregated_1s and recent_ticks
|
||||
extras = []
|
||||
if update_info:
|
||||
|
Reference in New Issue
Block a user