Yahoo Finance Options Quotes to Google Sheets?

Wayne

Active member
Aeromir Expert
Does anyone have an App Script for pulling Options data from a site like Yahoo finance?
 
There was a video that Tom made to import SPX historical data and I tried it to import RUT options data into excel and it worked
For some reason though it says Options data is not available for SPX
 
@Wayne, I think you are well-versed in Python. Yahoo! is funny about their quotes, as I use ^GSPC to get historical SPX equivalents, but I look under ^SPX for option chains. There's no history on the index there, only a daily quote.

Here's a snippet of Python script that pulls historical option data for SPX. In this example, it's the SPXW230203C04020000, AKA the Weekly Feb 3rd 4020 Call option. Perhaps this will be useful if you add on some iterations through the Expirations and Strikes of interest to pull history:

Python Code:
import time as tm
import datetime as dt
import pandas as pd

# period1 = int(tm.mktime(dt.datetime(2005, 1, 1, 23, 59).timetuple()))
period1 = int(tm.mktime(dt.datetime(2023, 1, 1, 23, 59).timetuple()))
period2 = int(tm.mktime(dt.datetime.now().timetuple()))
interval = '1d' # 1m, 1wk
path = r'C:\\Users\\daven\\Downloads\\'
# -- Quotes for SPX -- ****************************************************************
ticker = 'SPXW230203C04020000'
query_string = f'https://query1.finance.yahoo.com/v7/finance/download/{ticker}?period1={period1}&period2={period2}&interval={interval}&events=history&includeAdjustedClose=true'
# Load DataFrame
df = pd.read_csv(query_string)
print(df)

Output:

1675122949251.png
 
There was a video that Tom made to import SPX historical data and I tried it to import RUT options data into excel and it worked
For some reason though it says Options data is not available for SPX
Do you have a link to that vid?
 
Top
Contact Us