在使用yahoo finance时,我得到了以下错误。我不确定是什么导致了这个错误,一个小时前它工作正常,没有问题。
Exception in thread Thread-8:
Traceback (most recent call last):
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/site-packages/multitasking/__init__.py", line 102, in _run_via_pool
return callee(*args, **kwargs)
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/site-packages/yfinance/multi.py", line 167, in _download_one_threaded
data = _download_one(ticker, start, end, auto_adjust, back_adjust,
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/site-packages/yfinance/multi.py", line 179, in _download_one
return Ticker(ticker).history(period=period, interval=interval,
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/site-packages/yfinance/base.py", line 157, in history
data = data.json()
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/chandlergreff/opt/anaconda3/lib/python3.8/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)请找到我下面的代码
# yahoo finance parameters
stock_symbol = 'JPM'
length = 1
# yahoo date period
now = dt.datetime.now()
max_d = dt.datetime.now().strftime('%Y-%m-%d')
min_d = now.replace(year=now.year-length).strftime('%Y-%m-%d')
# yahoo data download
data = yf.download(stock_symbol, min_d, max_d) 发布于 2021-07-11 02:09:44
我升级了yfinance,代码运行正常。
下面是我正在运行的代码: data1 = yf.download(tickers = 'SPY',start=startdate,end=enddate) #股票指数
下面是我从Anaconda、environments、base(root)命令行运行的升级代码: pip install yfinance --upgrade --no-cache-dir
https://stackoverflow.com/questions/68320184
复制相似问题