aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/app.py b/app.py
index d196ae2..f4c0ce8 100644
--- a/app.py
+++ b/app.py
@@ -63,7 +63,7 @@ from components.insiders import render_insiders
from components.filings import render_filings
from components.news import render_news
from components.options import render_options
-from services.data_service import get_company_info, search_tickers
+from services.data_service import get_company_info, search_tickers, get_latest_price
if "ticker" not in st.session_state:
@@ -118,6 +118,24 @@ with st.sidebar:
info = get_company_info(ticker)
if ticker and info:
st.caption(info.get("longName", ticker))
+ price = get_latest_price(ticker)
+ prev_close = info.get("previousClose") or info.get("regularMarketPreviousClose")
+ if price is not None:
+ if prev_close and prev_close > 0:
+ chg = price - prev_close
+ chg_pct = chg / prev_close * 100
+ sign = "+" if chg >= 0 else ""
+ color = "#2ecc71" if chg >= 0 else "#e74c3c"
+ st.markdown(
+ f"<span style='font-size:1.3rem;font-weight:700'>${price:,.2f}</span>"
+ f"&nbsp;<span style='font-size:0.82rem;color:{color}'>{sign}{chg:+.2f} ({sign}{chg_pct:.2f}%)</span>",
+ unsafe_allow_html=True,
+ )
+ else:
+ st.markdown(
+ f"<span style='font-size:1.3rem;font-weight:700'>${price:,.2f}</span>",
+ unsafe_allow_html=True,
+ )
st.caption(f"Exchange: {info.get('exchange', '—')}")
st.caption(f"Currency: {info.get('currency', 'USD')}")
st.caption(f"Sector: {info.get('sector', '—')}")