yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Yahoo changed access?

Open GuyFBordelon opened this issue 3 years ago • 4 comments

I tried the code in the example of yfinance and it returns an error. Code: import yfinance as yf msft = yf.Ticker("MSFT")

get stock info

msft.info

get historical market data

hist = msft.history(period="max") Error: Traceback (most recent call last):

File "C:\Users\Win-7\anaconda3\lib\site-packages\requests\models.py", line 971, in json return complexjson.loads(self.text, **kwargs)

File "C:\Users\Win-7\anaconda3\lib\site-packages\simplejson_init_.py", line 525, in loads return _default_decoder.decode(s)

File "C:\Users\Win-7\anaconda3\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s)

File "C:\Users\Win-7\anaconda3\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end())

File "C:\Users\Win-7\anaconda3\lib\site-packages\simplejson\scanner.py", line 79, in scan_once return _scan_once(string, idx)

File "C:\Users\Win-7\anaconda3\lib\site-packages\simplejson\scanner.py", line 70, in _scan_once raise JSONDecodeError(errmsg, string, idx)

JSONDecodeError: Expecting value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "F:\AI\Wavelets\Production\untitled1.py", line 16, in hist = msft.history(period="max")

File "C:\Users\Win-7\anaconda3\lib\site-packages\yfinance\base.py", line 157, in history data = data.json()

File "C:\Users\Win-7\anaconda3\lib\site-packages\requests\models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

JSONDecodeError: Expecting value

GuyFBordelon avatar Jan 04 '23 22:01 GuyFBordelon

I can't get any earnings or other info although I don't get any errors during the call

msft.quarterly_balancesheet.size

0

smatzana avatar Jan 05 '23 02:01 smatzana

same thing here, nothing return with any of the method or attributes.

yumingchangsabodota avatar Jan 05 '23 09:01 yumingchangsabodota

I am experiencing the same issue with some of my apps in production. I think yahoo finance has revoked access to yfinance. The api is not working anymore.

It does work in development on my local machine, it could be a conflict with different versions of the package and python. Running some tests to see if that is the issue, will post on this thread if I was able to fix it.

Update

solution

package works fine, I had to delete env and reinstall packages then redeploy. It works now :)

nfaltir avatar Jan 05 '23 12:01 nfaltir

Deleted and reloading yfinance then using yfinance directly works. pandas datareader is not working. I bet you need to reload pandas. I tried updating pandas but that did not work.

GuyFBordelon avatar Jan 05 '23 20:01 GuyFBordelon