fix merge

This commit is contained in:
Dobromir Popov
2025-10-02 23:50:08 +03:00
parent 8654e08028
commit a468c75c47
13 changed files with 150 additions and 14309 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -296,15 +296,6 @@ class DashboardComponentManager:
logger.error(f"Error formatting system status: {e}")
return [html.P(f"Error: {str(e)}", className="text-danger small")]
<<<<<<< HEAD
def format_cob_data(self, cob_snapshot, symbol, cumulative_imbalance_stats=None, cob_mode="Unknown", imbalance_ma_data=None):
"""Format COB data into a split view with summary, imbalance stats, and a compact ladder."""
=======
def format_cob_data(self, cob_snapshot, symbol, cumulative_imbalance_stats=None, cob_mode="Unknown", update_info: dict = None):
"""Format COB data into a split view with summary, imbalance stats, and a compact ladder.
update_info can include keys: 'update_rate', 'aggregated_1s', 'recent_ticks'.
"""
>>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b
try:
if not cob_snapshot:
return html.Div([
@@ -353,21 +344,6 @@ class DashboardComponentManager:
asks = cob_snapshot.get('asks', []) or []
elif hasattr(cob_snapshot, 'stats'):
# Old format with stats attribute
<<<<<<< HEAD
stats = cob_snapshot.stats
mid_price = stats.get('mid_price', 0)
spread_bps = stats.get('spread_bps', 0)
imbalance = stats.get('imbalance', 0)
bids = getattr(cob_snapshot, 'consolidated_bids', [])
asks = getattr(cob_snapshot, 'consolidated_asks', [])
=======
stats = cob_snapshot.stats if isinstance(cob_snapshot.stats, dict) else {}
mid_price = float((stats or {}).get('mid_price', 0) or 0)
spread_bps = float((stats or {}).get('spread_bps', 0) or 0)
imbalance = float((stats or {}).get('imbalance', 0) or 0)
bids = getattr(cob_snapshot, 'consolidated_bids', []) or []
asks = getattr(cob_snapshot, 'consolidated_asks', []) or []
>>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b
else:
# New object-like snapshot with direct attributes
mid_price = float(getattr(cob_snapshot, 'volume_weighted_mid', 0) or 0)
@@ -405,18 +381,6 @@ class DashboardComponentManager:
pass
# --- Left Panel: Overview and Stats ---
<<<<<<< HEAD
overview_panel = self._create_cob_overview_panel(symbol, stats, cumulative_imbalance_stats, cob_mode, imbalance_ma_data)
=======
# Prepend update info to overview
overview_panel = self._create_cob_overview_panel(symbol, stats, cumulative_imbalance_stats, cob_mode)
if update_info and update_info.get('update_rate'):
# Wrap with a small header line for update rate
overview_panel = html.Div([
html.Div(html.Small(f"Update: {update_info['update_rate']}", className="text-muted"), className="mb-1"),
overview_panel
])
>>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b
# --- Right Panel: Compact Ladder with optional exchange stats ---
exchange_stats = (update_info or {}).get('exchanges') if isinstance(update_info, dict) else None
@@ -600,40 +564,6 @@ class DashboardComponentManager:
def aggregate_buckets(orders):
buckets = {}
for order in orders:
<<<<<<< HEAD
# Handle both dictionary format and ConsolidatedOrderBookLevel objects
if hasattr(order, 'price'):
price = order.price
size = order.total_size
volume_usd = order.total_volume_usd
else:
price = order.get('price', 0)
size = order.get('total_size', order.get('size', 0))
volume_usd = order.get('total_volume_usd', size * price)
=======
# Handle multiple formats: object, dict, or [price, size]
price = 0.0
size = 0.0
volume_usd = 0.0
try:
if hasattr(order, 'price'):
# ConsolidatedOrderBookLevel object
price = float(getattr(order, 'price', 0) or 0)
size = float(getattr(order, 'total_size', getattr(order, 'size', 0)) or 0)
volume_usd = float(getattr(order, 'total_volume_usd', price * size) or (price * size))
elif isinstance(order, dict):
price = float(order.get('price', 0) or 0)
size = float(order.get('total_size', order.get('size', 0)) or 0)
volume_usd = float(order.get('total_volume_usd', price * size) or (price * size))
elif isinstance(order, (list, tuple)) and len(order) >= 2:
price = float(order[0] or 0)
size = float(order[1] or 0)
volume_usd = price * size
else:
continue
except Exception:
continue
>>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b
if price > 0:
bucket_key = round(price / bucket_size) * bucket_size

View File

@@ -16,48 +16,6 @@ class DashboardLayoutManager:
self.dashboard = dashboard
def create_main_layout(self):
<<<<<<< HEAD
"""Create the main dashboard layout with dark theme"""
return html.Div([
self._create_header(),
self._create_chained_inference_status(),
self._create_interval_component(),
self._create_main_content(),
self._create_prediction_tracking_section() # NEW: Prediction tracking
], className="container-fluid", style={
"backgroundColor": "#111827",
"minHeight": "100vh",
"color": "#f8f9fa"
})
=======
"""Create the main dashboard layout"""
try:
print("Creating main layout...")
header = self._create_header()
print("Header created")
interval_component = self._create_interval_component()
print("Interval component created")
main_content = self._create_main_content()
print("Main content created")
layout = html.Div([
header,
interval_component,
main_content
], className="container-fluid")
print("Main layout created successfully")
return layout
except Exception as e:
print(f"Error creating main layout: {e}")
import traceback
traceback.print_exc()
# Return a simple error layout
return html.Div([
html.H1("Dashboard Error", className="text-danger"),
html.P(f"Error creating layout: {str(e)}", className="text-danger")
])
>>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b
def _create_prediction_tracking_section(self):
"""Create prediction tracking and model performance section"""
@@ -292,45 +250,6 @@ class DashboardLayoutManager:
], className="bg-dark p-2 mb-2")
def _create_interval_component(self):
<<<<<<< HEAD
"""Create the auto-refresh interval component"""
return html.Div([
dcc.Interval(
id='interval-component',
interval=1000, # Update every 1 second for maximum responsiveness
n_intervals=0
),
dcc.Interval(
id='minute-interval-component',
interval=60000, # Update every 60 seconds for chained inference
n_intervals=0
)
=======
"""Create the auto-refresh interval components with different frequencies"""
return html.Div([
# Fast interval for critical updates (2 seconds - reduced from 1s)
dcc.Interval(
id='interval-component',
interval=2000, # Update every 2000 ms (0.5 Hz) - OPTIMIZED
n_intervals=0
),
# Slow interval for non-critical updates (10 seconds - increased from 5s)
dcc.Interval(
id='slow-interval-component',
interval=10000, # Update every 10 seconds (0.1 Hz) - OPTIMIZED
n_intervals=0,
disabled=False
),
# Fast interval for testing (5 seconds)
dcc.Interval(
id='fast-interval-component',
interval=5000, # Update every 5 seconds for testing
n_intervals=0,
disabled=False
),
# WebSocket-based updates for high-frequency data (no interval needed)
html.Div(id='websocket-updates-container', style={'display': 'none'})
>>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b
])
def _create_main_content(self):
@@ -838,9 +757,3 @@ class DashboardLayoutManager:
], className="card-body p-2")
], className="card", style={"width": "30%", "marginLeft": "2%"})
], className="d-flex")
<<<<<<< HEAD
=======
>>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b