Registry / data / yfinance

yfinance

JSON →
library1.7.0pypypi✓ verified 24d ago

yfinance is a popular open-source Python library designed to access and retrieve financial market data from Yahoo! Finance. It simplifies fetching historical prices, financial statements, dividends, splits, and other relevant information for stocks, indices, and securities. The library is actively maintained with frequent updates, enabling users to efficiently perform financial analyses and gain insights.

pip install yfinance
INSTALL
IMPORT
SIG · YFINANCE
Y
yfinance
datapythonv1.7.0
Install
11.4s avg
Import
1990ms
Disk
225MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.180s · 225.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 11.4s · import 1.800s · 219MB
225MB installed
● package 225MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

yfinance
import yfinance as yf

This quickstart demonstrates how to download historical stock data for a given ticker symbol and how to access fundamental information about a company using the Ticker object.

import yfinance as yf import pandas as pd # Download historical data for a single ticker (e.g., Apple) ticker_symbol = "AAPL" data = yf.download(ticker_symbol, start="2023-01-01", end="2023-12-31") print(f"Downloaded {len(data)} rows for {ticker_symbol}:") print(data.head()) # Access information about a ticker ticker = yf.Ticker(ticker_symbol) info = ticker.info print(f"\nMarket Cap for {ticker_symbol}: {info.get('marketCap')}")
Debug
Known issues
breakingAs of version 1.2.0, the DataFrame returned by `yf.history()` is consolidated, which might cause 'read-only' errors in existing code if you attempt to modify it in place.
fix
If you need to modify the DataFrame, make a copy first: `df = yf.history().copy()` or use DataFrame methods that return a new DataFrame.
affects: >=1.2.0
breakingAround version 0.2.51 (December 2024), the data structure for downloaded data changed, often introducing a Multi-Index DataFrame. Additionally, the explicit 'Adjusted Close' column was removed as Open, High, Low, and Close prices are now automatically adjusted for dividends and splits.
fix
Adapt your code to handle Multi-Index DataFrames (e.g., using `.xs()` or `.droplevel()`) and rely on the automatically adjusted OHLC values. If migrating from older versions, verify your data processing logic.
affects: >=0.2.51 (likely applies to 1.x releases as well, upgrading from older 0.2.x)
deprecatedVersion 1.0 introduced deprecation warnings for the old configuration method.
fix
Refer to the official yfinance documentation for the updated configuration methods (e.g., `https://ranaroussi.github.io/yfinance/advanced/config.html`).
affects: >=1.0
gotchayfinance is an unofficial library that scrapes data from Yahoo Finance. As such, its functionality is subject to breaking if Yahoo Finance changes its website layout or API endpoints. Issues like cookie reuse or DNS blocking have historically occurred.
fix
Stay updated with the latest library versions and community discussions. Implement robust error handling (e.g., try-except blocks) in your code.
affects: All versions
gotchaIntraday data (intervals less than 1 day) has significant limitations: 1-minute data is only available for the last 7 days, and any intraday interval data is only available for the last 60 days. End-of-day data typically has a much longer history.
fix
Be aware of these time limitations when requesting intraday data. For longer historical periods, use daily or larger intervals.
affects: All versions
Upgrade
Version history
1.7.0latest on PyPI · released Aug 26, 2026
Audit
Dependencies
pandasrequiredEssential for DataFrame data structures returned by the library.
numpyrequiredUnderpins pandas for numerical operations.
requestsrequiredHandles HTTP requests to fetch data from Yahoo! Finance.
multitaskingrequiredFor asynchronous operations.
beautifulsoup4requiredUsed for parsing HTML content, likely in scraping scenarios.
curl-cffirequiredA newer, more robust HTTP client sometimes used for enhanced request handling.
Agent activity
94 hits · last 30 days
node
84
OpenAI (training)
1
Resources
yfinance — pip install yfinance · libregistry