fix merge
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user