aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorTyler <tyler@tylerhoang.xyz>2026-05-17 00:06:36 -0700
committerTyler <tyler@tylerhoang.xyz>2026-05-17 00:06:36 -0700
commit2b229cff5f99a00b6cc984f4c1c3c41de7f1e04c (patch)
tree706f19c58589aeef8bbfab6aa94a75daf50da70c /services
parent5424b83d8173435632dd59f4072d37ac68d33593 (diff)
Add 1D and 5D intraday periods to overview chart
Adds get_intraday_history() to data_service.py (5m/30m bars, ttl=60s) and wires it into the overview chart with HH:MM x-axis formatting, market-hours filtering, intraday-only primary fetch, hidden comparison buttons, and 1D as the default period on load. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'services')
-rw-r--r--services/data_service.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/services/data_service.py b/services/data_service.py
index 9c82e14..c481014 100644
--- a/services/data_service.py
+++ b/services/data_service.py
@@ -102,6 +102,20 @@ def get_price_history(ticker: str, period: str = "1y") -> pd.DataFrame:
return pd.DataFrame()
+@st.cache_data(ttl=60)
+def get_intraday_history(ticker: str, period: str, interval: str) -> pd.DataFrame | None:
+ """Return intraday OHLCV history. Use period='1d'/interval='5m' or period='5d'/interval='30m'."""
+ try:
+ t = yf.Ticker(ticker.upper())
+ df = t.history(period=period, interval=interval)
+ if df is None or df.empty:
+ return None
+ df.index = pd.to_datetime(df.index)
+ return df
+ except Exception:
+ return None
+
+
@st.cache_data(ttl=3600)
def get_income_statement(ticker: str, quarterly: bool = False) -> pd.DataFrame:
try: