yfinance review
yfinance reads prices, corporate actions, company metadata, financial statements, analyst data, options, news, screeners, and live quotes from Yahoo Finance into Python and pandas objects. Most calls need no API key because the library uses Yahoo's public-facing endpoints. Version 1.6.0 improves price repair and adds balance-sheet and screener fields. That breadth is convenient for research, but Yahoo does not affiliate with or vet the project, and the README limits its intended data use to research, education, and personal use. Treat it as an unofficial client whose upstream schema can change.
yfinance 1.6.0 is useful for exploratory market research when no-key access and pandas output matter. Do not make it the sole source for trading, financial reporting, or redistributed customer data.
We installed it
| Install | ✓ · 1.3s | 23 packages on disk · 160 MB |
| Import | ✓ | import yfinance in 2.11s · pure Python |
| Known vulns | 0 | (pip-audit) |
Answers from our run
Does yfinance install cleanly?
Yes. In a fresh container with an empty cache, pip install yfinance finished in 1 seconds, leaving 23 packages and 160 MB on disk. pip-audit reported no known vulnerabilities.
What does yfinance need to run?
Python 3.x, and nothing compiled: it is pure Python. In our run import yfinance succeeded in 2.11s.
yfinance or yahooquery: which should you use?
yahooquery: Use it for another unofficial Yahoo client whose batch-oriented quote-summary API better matches your research code. yfinance 1.6.0 is useful for exploratory market research when no-key access and pandas output matter.
When should you not use yfinance?
A commercial product will redistribute or display the data. The README says Yahoo Finance data is intended for personal use and directs users to Yahoo's terms for actual rights.
Use it if
- A notebook needs daily or recent intraday market history in a pandas DataFrame without an account setup step.
- Exploratory work needs dividends, splits, statements, options, holders, analyst fields, search results, or news behind one ticker object.
- A batch research job can record request settings, cache raw results, and tolerate occasional Yahoo endpoint changes or missing fields.
- Important prices and company facts will be checked against another source before a trade, filing, customer report, or published claim.
- A commercial product will redistribute or display the data. The README says Yahoo Finance data is intended for personal use and directs users to Yahoo's terms for actual rights.
- You need a service-level agreement, a contracted schema, exchange entitlements, or vendor support. yfinance is an unaffiliated community client for endpoints it does not control.
- The strategy needs deep intraday history. The `download` reference states that intraday intervals cannot extend beyond the latest 60 days.
- A small runtime cannot justify our measured 160 MB environment and 21 direct dependencies for a few HTTP fields. A licensed vendor client or scoped request may fit better.
- Downstream accounting or trading assumes every returned value is final. Adjustment defaults, missing fields, restatements, timezone choices, and optional repair can all change the DataFrame you analyze.
Setup reality
We installed yfinance 1.6.0 in a fresh Python 3.12 Bookworm container. The install completed in 1.3 seconds, left 23 packages, and used 160 MB on disk. The package declares 21 direct dependencies, is pure Python, uses Apache-2.0 licensing, and does not ship py.typed. PyPI does not specify a required Python range. import yfinance worked in 2.11 seconds. pip-audit found 0 known vulnerabilities.
Ordinary public-data calls need no API key, which also means there is no contracted endpoint. Yahoo can throttle requests, change cookie or crumb handling, omit a table, or rename fields before a yfinance release catches up. The project uses curl_cffi by default and documents a requests fallback. It stores timezone and cookie information in a local cache; set a writable cache location early in containers with read-only or temporary home directories.
Set download options explicitly. Current defaults include period='1mo', auto_adjust=True, threaded batches, and MultiIndex columns. A start date is inclusive and an end date is exclusive. Intraday history stops at the latest 60 days. Daily and intraday requests also have different default timezone handling. repair=True changes returned data while attempting to fix unit errors; PyPI defines a repair extra for its optional scientific dependencies.
Large threaded batches can attract throttling and still return partial columns, so split symbol sets, set timeouts, retry at the job boundary, and keep retrieval metadata beside cached data. Use .get() for optional company fields and inspect DataFrame indexes and columns before calculations. Record symbol, interval, adjustment, repair, timezone, package version, and fetch time. Cross-check splits, statements, and prices before financial decisions, and have the data owner review Yahoo's terms.
Patterns
Fetch one year of adjusted daily prices download-adjusted-history
import yfinance as yf
prices = yf.download(
'AAPL',
period='1y',
interval='1d',
auto_adjust=True,
progress=False,
multi_level_index=False,
timeout=15,
)
print(prices.tail())Set `auto_adjust` and `multi_level_index` explicitly so the DataFrame meaning does not depend on defaults.
Request an explicit date window download-date-range
prices = yf.download(
'MSFT',
start='2025-01-01',
end='2026-01-01',
actions=True,
auto_adjust=False,
progress=False,
)The start is inclusive and the end is exclusive. Here the last possible session falls before January 1, 2026.
Group a batch by ticker download-ticker-batch
panel = yf.download(
['AAPL', 'MSFT', 'NVDA'],
period='6mo',
group_by='ticker',
threads=4,
progress=False,
)
aapl_close = panel['AAPL']['Close']Batch results commonly use MultiIndex columns. Inspect `panel.columns` before hard-coding a selection.
Read recent five-minute bars fetch-intraday-bars
bars = yf.download(
'SPY',
period='5d',
interval='5m',
prepost=False,
progress=False,
timeout=15,
)The reference limits intraday data to the latest 60 days, and intraday indexes keep timezone information by default.
Keep raw closes beside corporate actions read-price-actions
ticker = yf.Ticker('AAPL')
history = ticker.history(
period='1y',
actions=True,
auto_adjust=False,
)
print(history[['Close', 'Dividends', 'Stock Splits']])An unadjusted Close is different from an adjusted series. Store the chosen flag with exported data.
Read the smaller fast-info view read-fast-quote-fields
quote = yf.Ticker('AAPL').fast_info
last_price = quote['last_price']
market_cap = quote['market_cap']fast_info avoids the broad company-info payload, but its values still come from Yahoo and can be absent.
Access company metadata defensively read-optional-company-info
info = yf.Ticker('MSFT').get_info()
company = {
'name': info.get('longName'),
'sector': info.get('sector'),
'currency': info.get('currency'),
}Use optional lookups. Yahoo may omit fields by symbol, market, or endpoint response.
Fetch annual and quarterly income statements read-income-statements
ticker = yf.Ticker('MSFT')
annual = ticker.get_income_stmt(freq='yearly')
quarterly = ticker.get_income_stmt(freq='quarterly')Line labels, units, periods, and availability vary. Preserve source timestamps and verify figures before reporting them.
Load the first available option expiry read-option-chain
ticker = yf.Ticker('AAPL')
expirations = ticker.options
if expirations:
chain = ticker.option_chain(expirations[0])
calls = chain.calls
puts = chain.putsThe expiry list may be empty or change between calls. Quotes can be delayed or incomplete.
Search quotes by company name search-symbols
search = yf.Search(
'Berkshire Hathaway',
max_results=5,
news_count=0,
timeout=15,
)
for quote in search.quotes:
print(quote.get('symbol'), quote.get('exchange'))Search results are suggestions from Yahoo. Confirm the exchange, quote type, and currency before fetching history.
Request price-unit repair repair-price-units
prices = yf.download(
'VOD.L',
period='5y',
repair=True,
auto_adjust=False,
progress=False,
)Repair can change returned values while looking for unit errors. Log the flag and compare repaired output with the raw series.
Move yfinance cache files configure-cache-location
import yfinance as yf
yf.set_tz_cache_location('/var/tmp/market-cache/yfinance')
prices = yf.download('AAPL', period='1mo', progress=False)Call this before the first request and ensure the directory is writable. Use persistent storage if cookie and timezone reuse matters across restarts.
Alternatives
| Package | Registry | Pick it when |
|---|---|---|
| yahooquery | PyPI | Use it for another unofficial Yahoo client whose batch-oriented quote-summary API better matches your research code. |
| pandas-datareader | PyPI | Use it when one pandas interface across several public economic and market-data sources matters more than Yahoo breadth. |
| alpha-vantage | PyPI | Use it when an API key, published vendor limits, and a documented provider relationship are preferable to anonymous Yahoo access. |
More data guides
numpy · fsspec · pandas · sqlalchemy · pyarrow · lxml · the whole shelf →
How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.

