"""Market bar — displays major indices at the top of the app.""" import streamlit as st from services.data_service import get_market_indices 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") value = f"{price:,.2f}" if price is not None else "—" delta_class = _delta_class(change_pct) delta_text = _delta_text(change_pct) col.markdown( f"""