explaingit

ranaroussi/yfinance

📈 Trending23,704PythonAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Python library that downloads stock prices, company financials, and market data from Yahoo Finance with a simple, easy-to-use interface.

Mindmap

mindmap
  root((yfinance))
    What it does
      Download stock prices
      Fetch company financials
      Stream live updates
      Get market data
    How to use it
      Simple Python interface
      Works with pandas
      Install via pip
      One-liner queries
    Use cases
      Investment research
      Backtest strategies
      Build analysis tools
      Academic studies
    Tech stack
      Python
      pandas
      WebSocket
      Yahoo Finance API

Things people build with this

USE CASE 1

Download historical stock prices and analyze them in Python for personal investment decisions.

USE CASE 2

Backtest trading strategies by fetching years of price data and running simulations.

USE CASE 3

Build a financial dashboard that pulls live company earnings, balance sheets, and market data.

USE CASE 4

Conduct academic research on stock market trends using clean, pandas-ready historical data.

Tech stack

PythonpandasWebSocket

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose including commercial. Keep the notice and disclose changes to the patent grant.

In plain English

yfinance is a Python library that lets you download financial and market data from Yahoo Finance. The problem it solves is access: Yahoo Finance has a wealth of stock prices, historical data, company financials, and market information, but getting that data into a Python program for analysis or research normally requires navigating complex APIs. yfinance wraps those APIs into a simple, Pythonic interface, meaning it follows Python's conventions for how code should look and behave. With yfinance you can fetch historical price data for a single stock or multiple tickers at once, get company information like earnings and balance sheets, retrieve sector and industry data, search for quotes and news, and even stream live price updates via a WebSocket connection (a type of persistent connection that pushes updates in real time). The data comes back in a format compatible with pandas, the popular Python data-analysis library, making it ready for immediate analysis, charting, or feeding into financial models. You would use this for personal investment research, building financial analysis tools, backtesting trading strategies, or academic work involving stock market data. It is intended for research and educational use only, Yahoo Finance's own terms limit the API to personal use, and yfinance is not affiliated with or endorsed by Yahoo. The library is installed via pip and works with Python 2.7 and Python 3.6 or later.

Copy-paste prompts

Prompt 1
Show me how to use yfinance to download the last 5 years of Apple stock prices and calculate the average monthly return.
Prompt 2
Write a Python script using yfinance that fetches earnings data and balance sheet info for multiple stocks at once.
Prompt 3
How do I set up yfinance to stream live stock price updates for a watchlist of tickers?
Prompt 4
Use yfinance to backtest a simple moving-average crossover strategy on historical S&P 500 data.
Prompt 5
Show me how to get sector and industry data for a stock using yfinance and compare it to competitors.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.