Get Free Options Data with Python: Yahoo finance & Pandas Tutorial

by John

 

Options data is hard to come by for a cheap price, that's why it might be recommended to begin your own collection process. In this post we will show how to download options chain data for Tesla, Amazon and many other top US listed companies all with Python. 

It is also worth noting that options data bid/ ask prices will only be available during trading hours 9.30am ET - 4pm ET and also bear in mind that the data is on a short delay of approximately 15 minutes. 

 

 

Install yfinance Package 

 

The yfinance package is probably the best package you will find for interacting with Yahoo Finance data in general & especially for their options data

 

# install yahoo finance package
pip install yfinance

 

 

Create Python Object for Given Stock Options

 

In this example we will use Tesla. Note you can change this by looking for a listed stock on Yahoo finance and finding the corresponding ticker and then just changing it here. 

 


import yfinance as yf

# create a Ticker object for Tesla Stock
tsla= yf.Ticker("TSLA")

 

 

List Available Options Expiry Dates

 

Expiries refers to the available dates Tesla options are listed for. On Yahoo finance this can be found in same place as screenshot below 

 

Tesla Options Data with Python

 

 

# list all available option expiry dates
expiries = tsla.options
print("Available expiries:", expiries)


'''
Available expiries: ('2025-04-25', '2025-05-02', '2025-05-09', '2025-05-16', '2025-05-23', '2025-05-30', '2025-06-20', '2025-07-18', '2025-08-15', '2025-09-19', '2025-10-17', '2025-11-21', '2025-12-19', '2026-01-16', '2026-03-20', '2026-06-18', '2026-09-18', '2026-12-18', '2027-01-15', '2027-06-17', '2027-12-17')
'''

 

 

 

Get Put and Call Options Data. 

 

Now that we have a list of expiries, we can find the relevant call and put options chains for a given expiry. Here will we take the first expiry as an example, which is how we can find 0DTE options for Tesla. Note the output example for call options in red. 

 

# pick an expiry (e.g. the first one)
expiry = expiries[0]

# fetch the option chain for that expiry
opt_chain = tsla.option_chain(expiry)

# opt_chain.calls and opt_chain.puts are both pandas DataFrames
calls = opt_chain.calls
puts  = opt_chain.puts

print("\nCalls:\n", calls.head())
print("\nPuts:\n",  puts.head())


'''

Calls:
         contractSymbol             lastTradeDate  strike  lastPrice     bid  \
0  TSLA250425C00050000 2025-04-21 13:54:22+00:00    50.0     174.51  176.30   
1  TSLA250425C00070000 2025-04-17 19:59:11+00:00    70.0     170.81  155.60   
2  TSLA250425C00075000 2025-04-17 19:59:11+00:00    75.0     166.15  150.65   
3  TSLA250425C00080000 2025-04-17 19:09:57+00:00    80.0     160.27  145.65   
4  TSLA250425C00085000 2025-04-17 19:09:57+00:00    85.0     155.30  140.65   

      ask     change  percentChange  volume  openInterest  impliedVolatility  \
0  178.90 -14.700012      -7.769152    12.0            12           5.046879   
1  159.70   0.000000       0.000000     2.0             8           4.148442   
2  154.70   0.000000       0.000000     2.0             6           3.992188   
3  149.70   0.000000       0.000000     4.0             6           3.773438   
4  144.75   0.000000       0.000000     4.0             4           3.625001   

   inTheMoney contractSize currency  
0        True      REGULAR      USD  
1        True      REGULAR      USD  
2        True      REGULAR      USD  
3        True      REGULAR      USD  
4        True      REGULAR      USD  

'''

 

 

Yahoo Finance Options Data Explained

 

The table below gives a brief explanation on each of the columns that are now available in our Python program.

 

Column Name Description
contractSymbol The unique identifier for this option contract, encoding the underlying ticker, expiration date, option type (C/P), and strike price.
lastTradeDate Timestamp (ISO 8601) of the most recent trade for this option, including timezone (e.g. UTC).
strike The strike price at which the option can be exercised.
lastPrice The price at which the option last traded.
bid The current highest price that a buyer is willing to pay for the option.
ask The current lowest price that a seller is willing to accept for the option.
change The absolute change in the option’s price since the previous trading session’s close.
percentChange The percentage change in price relative to the previous close.
volume The total number of option contracts traded for this symbol on the current trading day.
openInterest The total number of outstanding option contracts that have not been exercised or closed.
impliedVolatility The market’s forecast of the underlying asset’s volatility, expressed as a decimal (e.g. 0.25 = 25%).
inTheMoney Boolean indicating whether the option is currently “in the money” (True) or not (False).
contractSize The size of one contract (e.g. “REGULAR” typically means 100 shares per contract).
currency The currency in which the option prices are quoted (e.g. USD).

 

 


 

What's next? 

 

Now you have an easy way to get the latest options data for any listed option on Yahoo finance. All with only a few lines of code! Perhaps you might want to try out calculating implied volatility. Or learn to run Python scripts in the cloud to create your own database. Feel free to check out the links below for some good starting points! Or check out the next post about calculating custom options indicators.

 

📚 Further Reading