From b1e129bff08076fcd7dfe3ef9c3a98c8f1712a26 Mon Sep 17 00:00:00 2001 From: Openclaw Date: Sun, 29 Mar 2026 01:33:07 -0700 Subject: Improve UX and disable DCF for financials --- components/market_bar.py | 84 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 10 deletions(-) (limited to 'components/market_bar.py') diff --git a/components/market_bar.py b/components/market_bar.py index cb813e5..411b232 100644 --- a/components/market_bar.py +++ b/components/market_bar.py @@ -1,25 +1,89 @@ """Market bar — displays major indices at the top of the app.""" import streamlit as st from services.data_service import get_market_indices -from utils.formatters import fmt_number + + +def _delta_class(change_pct: float | None) -> str: + if change_pct is None: + return "neutral" + return "positive" if change_pct >= 0 else "negative" + + +def _delta_text(change_pct: float | None) -> str: + if change_pct is None: + return "—" + arrow = "▲" if change_pct >= 0 else "▼" + return f"{arrow} {change_pct * 100:+.2f}%" def render_market_bar(): indices = get_market_indices() + st.markdown( + """ + + """, + unsafe_allow_html=True, + ) + cols = st.columns(len(indices)) for col, (name, data) in zip(cols, indices.items()): price = data.get("price") change_pct = data.get("change_pct") - if price is None: - col.metric(label=name, value="—") - continue + value = f"{price:,.2f}" if price is not None else "—" + delta_class = _delta_class(change_pct) + delta_text = _delta_text(change_pct) - price_str = f"{price:,.2f}" - delta_str = f"{change_pct * 100:+.2f}%" if change_pct is not None else None - col.metric( - label=name, - value=price_str, - delta=delta_str, + col.markdown( + f""" +
+
{name}
+
{value}
+ {delta_text} +
+ """, + unsafe_allow_html=True, ) -- cgit v1.3-2-g0d8e