I've been using yfinance for a while. When I went on holiday downloading data with yfinance and pandas_datareader stopped working for me. I guessed it was caused by something to do with a different connection. When I arrived back from holiday I still had issues with my code that I've used before without issues. I don't understand the error message and would appreciate if anybody could help resolve the issue.
This is some basic code:
import pandas as pd
import yfinance as yf
import datetime as dt
start = dt.date(2020,1,1)
end = dt.date(2021,1,1)
ticker = 'AAPL'
df = yf.download(ticker,start,end)
print(df)
This code has worked for me in the past however I now receive the following error message:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/multitasking/__init__.py", line 102, in _run_via_pool
return callee(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/yfinance/multi.py", line 168, in _download_one_threaded
actions, period, interval, prepost, proxy, rounding)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/yfinance/multi.py", line 183, in _download_one
rounding=rounding, many=True)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/yfinance/base.py", line 157, in history
data = data.json()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
try reinstalling/upgrading yfinance
and execute this code. its working for me.
sudo python3 -m pip install --upgrade yfinance