Quick answer
yfinance is a popular open-source Python library that downloads data from Yahoo Finance: historical prices (yf.download), dividends and splits, options chains, financial statements and more, as pandas DataFrames. It uses unofficial endpoints, so it can break or be rate-limited when Yahoo changes things; production systems usually pair it with a paid source.
yfinance at a glance
- Category
- Broker, exchange & data libraries
- Language
- Python
- License
- Apache-2.0
- Does
- Market data
- Markets
- Stocks, ETFs, Indices, Forex, Crypto, Futures, Options, Fundamentals
- Best for
- Free research data for stocks, ETFs, indices, FX and crypto.
- In AlgoGP
- Use the exported strategy object from your own code
Pick it if
Free research data for stocks, ETFs, indices, FX and crypto.
Watch out for
Unofficial: rate limits and breakages happen.
yfinance strengths and limitations
Strengths
- Free, no key.
- Broad coverage including fundamentals and options.
- Simple pandas output.
Limitations
- Unofficial: rate limits and breakages happen.
- Not licensed for commercial redistribution.
yfinance example
pip install yfinanceimport yfinance as yf
data = yf.download(["SPY", "QQQ"], start="2020-01-01", auto_adjust=True)
print(data["Close"].tail())Use yfinance with AlgoGP
AlgoGP does not add yfinance to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from yfinance yourself.
- 1
Design and backtest in AlgoGP
Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.
- 2
Add any bridge to get the adapter core
Adding a bridged framework (for example Backtrader) writes
frameworks/algogp_bridge.py, whoseStrategyBridge.on_bar()returns the orders the strategy wants. - 3
Call it from yfinance
Feed yfinance’s bars to
StrategyBridge, place the returned orders with yfinance, and report fills back withsync().
yfinance connects to Yahoo Finance. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.
yfinance: frequently asked questions
Why is yfinance rate limited?
Yahoo throttles unofficial access; cache data, slow requests, or use a keyed API.
Does AlgoGP need yfinance?
No; exported projects read Yahoo’s chart endpoint with the standard library, and in-app backtests use AlgoGP’s own data.
yfinance alternatives
- OpenBBPythonOpen-source investment research platform: one Python interface to dozens of data providers for equities, crypto, macro, options and fixed income.
- CCXTPython, JavaScript, TypeScript, PHP, C#, GoOne unified API for 100+ crypto exchanges in Python, JavaScript, PHP, C# and Go: market data, balances and orders with the same calls everywhere.
- alpaca-pyPythonAlpaca’s official Python SDK for its Trading, Market Data and Broker APIs: stocks, options and crypto, REST and WebSocket streams.
- CryptofeedPythonNormalized real-time crypto market-data feeds (trades, books, funding, liquidations) from dozens of exchanges over WebSockets, with storage backends.
Independent guide. AlgoGP is not affiliated with yfinance. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.