Community (unofficial Yahoo Finance)
yfinance — The notebook favourite: one line for a ticker's history or option chain — unofficial, throttled, and not for jobs
In a notebook, for a quick look: a ticker's history, its option chain, a few fundamentals — where being throttled or broken next week is an inconvenience, not an incident.
Reach for it when…
In a notebook, for a quick look: a ticker's history, its option chain, a few fundamentals — where being throttled or broken next week is an inconvenience, not an incident.
Not for: Anything unattended or repeated (it 429s within minutes from a bare loop and breaks whenever Yahoo changes a page), anything commercial, anything you will redistribute.
Units, revisions, traps
Units. Prices in the listing currency; 'Adj Close' includes dividends and splits. Intervals below daily are limited to recent history (1-minute: 7 days).
Revisions. Whatever Yahoo shows today.
- Bare loops get 429 Too Many Requests; use requests_cache and a delay, and expect it to break.
- The library's column names and behaviour change between versions (auto_adjust default flipped in 2025).
- Symbols are Yahoo's: 005930.KS for Samsung, ^KS11 for the KOSPI.
Classic mistake: Scheduling a daily job on yfinance and discovering a month of gaps.
Three recipes
Each recipe: Python · Excel · Sheets, with how to read the result. Python recipes run under pandas; recipe 1 is re-run by the weekly check where the source allows it.
How to use it in your own work
Copy the snippet, change the series id, read the result the way the footer says. Replace YOUR_…_KEY with your own key where one is needed.
Recipe 1One ticker's history
# pip install yfinance requests_cache
import yfinance as yf
import requests_cache
session = requests_cache.CachedSession("yf.cache", expire_after=3600)
df = yf.download("AAPL", period="1y", auto_adjust=True, session=session, progress=False)
print(df.tail())- Not applicable — yfinance is a Python library.
- Not applicable; Sheets has GOOGLEFINANCE() for a quick quote.
Recipe 2An option chain
import yfinance as yf
t = yf.Ticker("AAPL")
exp = t.options[0]
chain = t.option_chain(exp)
print(exp); print(chain.calls[["strike", "lastPrice", "impliedVolatility", "openInterest"]].head())- Not applicable.
- Not applicable.
Recipe 3What to use instead for a job
# the same daily bars from a source with terms: Twelve Data (free tier) — see its card
import requests, pandas as pd
u = "https://api.twelvedata.com/time_series?symbol=AAPL&interval=1day&outputsize=30&apikey=demo"
df = pd.DataFrame(requests.get(u, timeout=30).json()["values"]).set_index("datetime").astype(float).sort_index()
print(df.tail())- Use a licensed source's CSV endpoint.
- Use a licensed source's CSV endpoint.
Series → question map
The ids we use from yfinance, each with the question it answers. The catalog's compare view reads the concept tags behind these rows.
| Series | Answers | Region | Concept |
|---|---|---|---|
| download(ticker) | A ticker's daily history | global | ohlc_daily |
| Ticker.option_chain | An option chain by expiry | United States | options |
| download(^KS11) | An index quickly | global | equity_index |
| Ticker.info | A few fundamentals quickly | global | fundamentals |
Compare with
Same question, different source: Twelve Data, Stooq, Polygon.io. The compare view lines up coverage, frequency, history and access side by side and lists what the combination makes possible.
Questions readers ask
Is yfinance legal?
It is a scraper of Yahoo's pages and endpoints; Yahoo's terms forbid automated use. Fine for personal exploration, not for anything commercial or redistributed.
Why does it stop working?
Yahoo changes endpoints and throttles; the library catches up in a release or two. That is the deal.
What should a job use instead?
A source with terms: Twelve Data, EODHD, Polygon, Tiingo for prices; FRED and central banks for macro.
Educational only — we explain, we never advise · snippet licence: public domain · corrections to [email protected], fixed within a day and logged in the changelog.