Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to download data from yahoo on 01/13/2023 #958

Open
yuzhipeter opened this issue Jan 14, 2023 · 10 comments
Open

Fail to download data from yahoo on 01/13/2023 #958

yuzhipeter opened this issue Jan 14, 2023 · 10 comments

Comments

@yuzhipeter
Copy link

Hello,

Data download fails from yahoo finance. The error msg is

df = web.DataReader("SPY", data_source='yahoo', start='2020-01-01', end='2020-03-03', session = sesh)
Traceback (most recent call last):

File "C:\Users\peter\AppData\Local\Temp/ipykernel_25324/3322276019.py", line 1, in
df = web.DataReader("SPY", data_source='yahoo', start='2020-01-01', end='2020-03-03', session = sesh)

File "C:\Users\peter\anaconda3\lib\site-packages\pandas\util_decorators.py", line 207, in wrapper
return func(*args, **kwargs)

File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\data.py", line 370, in DataReader
return YahooDailyReader(

File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\base.py", line 253, in read
df = self._read_one_data(self.url, params=self._get_params(self.symbols))

File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py", line 231, in _read_one_data
data = new_j['HistoricalPriceStore']

UnboundLocalError: local variable 'new_j' referenced before assignment

It was good yesterday, 01/12/2023. Thanks!

@devmsft-github
Copy link

Assume you installed pandas-datareader using this command
pip install git+https://github.com/raphi6/pandas-datareader.git@ea66d6b981554f9d0262038aef2106dda7138316

Faced the same issue today, but based on this commit, overwrote these 3 files:

folder = /path/to/env/env-name/Lib/site-packages

1) pandas_datareader/tests/io/test_jsdmx.py
2) pandas_datareader/tests/yahoo/test_options.py
3) pandas_datareader/yahoo/daily.py

Working as expected, waiting for Issue #952 merge to main branch and a release soon.

@yuzhipeter
Copy link
Author

It works now. Thanks!

@AnOniMaTe32
Copy link

@devmsft-github how did you overwrite the 3 files?

@devmsft-github
Copy link

  1. Saved the 3 original files that came with the pip install to [filename]_orig.py
  2. from this commit, copied the content of the newest version of file_1
  3. Opened [file_1].py under /path/to/env/Lib/site-packages and pasted content from (2)
  4. Repeat for file_2 & file_3

@yuzhipeter
Copy link
Author

The new files are broken again with yahoo finance

df = web.DataReader("SPY", data_source='yahoo', start='2023-01-01', end='2023-01-13', session = sesh)

Error msg

Traceback (most recent call last):

File "C:\Users\peter\AppData\Local\Temp/ipykernel_27516/630144412.py", line 1, in
df = web.DataReader("SPY", data_source='yahoo', start='2023-01-01', end='2023-01-13', session = sesh)

File "C:\Users\peter\anaconda3\lib\site-packages\pandas\util_decorators.py", line 207, in wrapper
return func(*args, **kwargs)

File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\data.py", line 370, in DataReader
return YahooDailyReader(

File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\base.py", line 253, in read
df = self._read_one_data(self.url, params=self._get_params(self.symbols))

File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py", line 227, in _read_one_data
new_j = decrypt_cryptojs_aes(

File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py", line 81, in decrypt_cryptojs_aes
plaintext = unpad(plaintext, 16, style="pkcs7")

File "C:\Users\peter\anaconda3\lib\site-packages\Crypto\Util\Padding.py", line 92, in unpad
raise ValueError("Padding is incorrect.")

ValueError: Padding is incorrect.

Thanks!

@yuzhipeter yuzhipeter reopened this Jan 28, 2023
@devmsft-github
Copy link

This time went the route of yfinance as below

import yfinance as yf
yf.pdr_override()

then

data = yf.download(ticker, start=start_date, end=end_date, threads=False) # or threads=True

This works with raphi6's pandas-datareader fixes I suggested above, so all you need is yfinance.

@fouad09
Copy link

fouad09 commented Feb 1, 2023

This still not working !!!

@suaide
Copy link

suaide commented Feb 6, 2023

No update on this issue? Is pandas-datareader abandoned?

@devmsft-github
Copy link

pandas-datareader works as expected with the yfinance fix above.

What is not working?

@Luminilion
Copy link

Hey there,
The yfinance module offers an override of the yahoo finance from datareader.
It only requires to add one line.

from pandas_datareader import data as pdr

import yfinance as yf
yf.pdr_override() # <== that's all it takes :-)

# download dataframe
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")

You can check the comment on the official yfinance repo -> here

Hope it helps, it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants