"""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 render_market_bar(): indices = get_market_indices() 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 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, )