blob: cb813e5f5d2205f1ffdc6395060f55244dc015d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
"""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,
)
|