If data is the King, then how about free data!? Yahoo Finance used to have its own financial API, but this was decommissioned in 2017. But Ran Aroussi (thank you! thank you! thank you!) developed this library to come and fill the gap!
As for all the good things about Python modules, you can find it at pypi.org. There is nothing particular about installation and it should go smoothly. For this story, I assume that you have a basic understanding of Python and trading, so I will spare your time explaining terminology that a basic Python user for trading is aware of.
Pros and cons
The pros are numerous
- It is Free!
- Supports various asset types (shares, ETF, forex, crypto, and much more)
- Support various time frames from 1 minute to 3 months for historical data
- Includes fundamental data besides OHLC prices
- Returns a pandas dataframe for prices, which is the market standard when it comes to data analysis
There are some cons though:
- It is free, so there is no dedicated support. This means that it is great for research and backtesting. But when there is real money in the game you should depend on a paid service
- It has limitations on the amount of historical data you can get. For example, the 1-minute timeframe can only get 7 days of data, and anything less than a day candle, up to 60 days
- You cannot exploit it. If you run hundreds of thousands of calls, there is a good chance that your IP will be blocked from Yahoo. Especially if you use some VPN there is a pretty good chance that this IP is blocked. At the end of the day, it is a scrapping tool!
The Ticker!
The first thing that you need — that is a surprise — is the symbol of the asset that you are interested in. Unfortunately, there is no way to get this through some function or API call, as you would do with any provider of a similar paid service or your broker.
However, the good news is that it is easy to guess it. While browsing assets in your browser, you can see the ticker symbol on the URL. For example, this link https://finance.yahoo.com/quote/AAPL is for Apple, so the ticker symbol is AAPL.
For major stock exchanges, the tickers are the standard symbols. This means that you can download any list of symbols out there and there is a good chance that this will work. In my article below for developing a custom stock screener, you can find a list you can start with.
Some further tips to understand the various tickers you can get:
- Indices start with caret (^). E.g. S&P 500 symbol is ^GSPC ( YF link)
- Forex pairs end with =X. E.g. EUR/USD is EURUSD=X (YF link)
- Cryptos are priced vs USD with a dash. E.g. Bitcoin is BTC-USD (YF link)
- Futures end with =F. E.g. Gold future is GC=F. (YF link)
Let’s get into Python now. To get the ticker it is as simple as below
import yfinance as yf
# get stock ticker
ticker = yf.Ticker("MSFT")
Now that you have the ticker you can explore the enormous amount of information it has. News, calendar, dividends, corporate actions, balance sheet data, and much more.
Check out my GitHub notebook which has the results of all the properties of a ticker object.
However, you must know that most information is for stocks. For currencies, crypto, ETFs or indices, you should stick to the basics like info, news, and that is pretty much it for fundamental data. For example the property calendar does not work for currencies. It is a property build for equities corporate actions.

History
Well, we talked about the history of the module. This is about the history method of the ticker. As soon as you have the ticker, using the history method you can get a panda’s dataframe object, with the OHLC prices of the ticker, together with some information about Volume, Dividents, and Splits
history = ticker.history(period="10y")

You can customize what you query, using quite a few parameters. The most needed are:
- period: the period you want to get. Last 1mo (1 month) is the default, but you can use any (e.g. 10y for 10 years)
- interval: is the timeframe of your data. 1d (1 day) is the default, but you can use anything like 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
- start and end: is the case that you want to be specific about the period. Do not use it together with the period, since I have noticed some strange behavior in some cases.
Tip: Use period=”max” and you will get the full history available for this asset. With a daily timeframe, I got for Apple all the prices from 1980 and for EURUSD from 2003!
As long as you have called history, you can get also some metadata that will provide some information for the asset.
ticker.history_metadata
This metadata includes information about the last called history, together with some data for the ticker. It comes in handy when you use the same object to call history in a loop.
History works for all the asset types, and a notebook with sample code is available on my GitHub.
Download
An alternative method to get historical pricing of an asset is to use the download method. This, as history does, returns a pandas dataframe with pricing and uses mostly the same parameters like period, interval, start, and end.
yf.download("AMZN", period="1mo", interval="1d")
Multiple Tickers
Both history and download can work with multiple tickers at once. Let’s see with history first:
tickers = yf.Tickers("AAPL TSLA NVDA AMD AMZN FB MSFT GOOGL")
for ticker in tickers.symbols:
print(f'The current bid price for {tickers.tickers[ticker].ticker} is {tickers.tickers[ticker].info["bid"]}')
tickers.tickers['AAPL'].history('1mo')
You should pass a sting delimited with space for all the assets you are interested in. You get back a tickers object which includes the list of symbols (so you can iterate on that one) and a dictionary with all the tickers you requested. You can easily iterate through the dictionary and control the information that you will be using
With the download method, you just need to define a list with all your tickers instead of a string:
tickers = ["AAPL", "TSLA", "NVDA", "AMD", "AMZN", "MSFT", "GOOGL"]
yf.download(tickers, period="1mo", interval="1d")
This way you get all the prices at once in a single pandas dataframe with multi-level columns as looks below:

Multilevel columns are a bit tricky. One use case where you will need to download multiple tickers in one dataframe is to have one column for each item with the Adjusted Close price and the ticker name as the column name. The code to do that easily and remove the multilevel column name is below:
df
tickers = ["AAPL", "TSLA", "NVDA", "AMD", "AMZN", "MSFT", "GOOGL"]
df = yf.download(tickers, start='2014-01-01', end='2023-12-31', interval='1d')['Adj Close']
# so far still you got the ticker level. to make it cleared run the below
df.columns.name = None

Conclusion
In summary, Ran Aroussi’s Python library fills the gap left by Yahoo Finance’s decommissioned API, providing free access to diverse financial data. While offering valuable features like historical data and asset support, it’s essential to note limitations such as the absence of dedicated support and the potential for IP blocking with excessive calls. Overall, it stands as a useful tool for research and backtesting in trading.