yfinance下载数据时返回错误

zujrkrfu  于 2021-09-08  发布在  Java
关注(0)|答案(1)|浏览(702)

我在使用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)
ijnw1ujt

ijnw1ujt1#

我升级了yfinance,代码正常运行。
下面是我正在运行的代码:data1=yf.download(股票代码='spy',start=startdate,end=enddate)#股票指数
下面是我从anaconda、environments、base(root)命令行运行的升级代码:pip install yfinance--upgrade--no cache dir

相关问题