Closed HyperionSounds closed 1 year ago
Looks like something has changed in how Yahoo formats its pages.
The line 'option_dates = [a.get_text() for a in soup.find_all('option')]' would normally pick up all the unix timestamps on here https://finance.yahoo.com/quote/%5ESPX/options?p=%5ESPX
I can see the page in the browser (and the 'option' tags in the developer window) but they aren't getting found by BeautifulSoup anymore so I'll have to see if there's any other solution.
OK. I've updated the URLOpener and it is working again for me now. Version 1.1.2 now on PyPi. Readme has been updated as well to include instructions for Python venv which is more straightforward if you don't have anaconda installed.
Did standard install described using new anacoda environment, tried the template script and no dice.
(volvis):Volatility $ python volvisualizer\ template.py
URL's extracted
Options data extracted
Traceback (most recent call last):
File "/Users/Documents/Code/python/Finance/Volatility/volvisualizer template.py", line 2, in
imp = Volatility(ticker='SPY', start_date='2022-8-12', wait=0.5, monthlies=True, q=0.013)
File "/Users/opt/anaconda3/envs/volvis/lib/python3.9/site-packages/volvisualizer/volatility.py", line 100, in init
params, tables = Data.create_option_data(params=params, tables=tables)
File "/Users/opt/anaconda3/envs/volvis/lib/python3.9/site-packages/volvisualizer/market_data.py", line 103, in create_option_data
params, tables = DataPrep.transform(params=params, tables=tables)
File "/Users/opt/anaconda3/envs/volvis/lib/python3.9/site-packages/volvisualizer/market_data_prep.py", line 79, in transform
tables['data']['Last Trade Date'])
File "/Users/opt/anaconda3/envs/volvis/lib/python3.9/site-packages/pandas/core/frame.py", line 3761, in getitem
indexer = self.columns.get_loc(key)
File "/Users/opt/anaconda3/envs/volvis/lib/python3.9/site-packages/pandas/core/indexes/range.py", line 349, in get_loc
raise KeyError(key)
KeyError: 'Last Trade Date'
(volvis):Volatility $