aboutsummaryrefslogtreecommitdiff
path: root/components/market_bar.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/market_bar.py')
-rw-r--r--components/market_bar.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/components/market_bar.py b/components/market_bar.py
new file mode 100644
index 0000000..cb813e5
--- /dev/null
+++ b/components/market_bar.py
@@ -0,0 +1,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,
+ )