gpt4 book ai didi

python - yfinance 下载数据时返回错误

转载 作者:行者123 更新时间:2023-12-05 01:58:45 31 4
gpt4 key购买 nike

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

最佳答案

我升级了 yfinance 并且代码有效。

这是我正在/正在运行的代码:data1 = yf.download(tickers = 'SPY', start=startdate, end=enddate) # 股票指数

这是我从 Anaconda、环境、基础(根)命令行运行的升级代码:pip install yfinance --upgrade --no-cache-dir

关于python - yfinance 下载数据时返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68320184/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com