aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorTyler <tyler@tylerhoang.xyz>2026-03-31 00:32:02 -0700
committerTyler <tyler@tylerhoang.xyz>2026-03-31 00:32:02 -0700
commit33ec0e8998a2088f76171e493cc207e8dd10ad5a (patch)
treec868618cbd15c63826884f8766fdff51ef35c0cc /app.py
parentc5575a1760a88e486e354e56be68bdb75d053db6 (diff)
Add live price + daily change to sidebar
Shows current price, $ change, and % change (green/red) below the company name so the stock price is always visible while navigating tabs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'app.py')
-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', '—')}")