Skip to content

Getting this Error: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #877

Description

@MaximilianPannenbaecker

Hallo I am keep getting an Error for different scripts her an exampl script:
`tickers = gettickers('mdax')
days = 30
returns, symbols = [], []
klines = {}
for ticker in tickers[]:
klines[ticker] = yf.download(ticker.upper(), interval='1d', period=f'{days}d', threads=False)
if len(klines[ticker]) > 0:
cumret = (pd.DataFrame(klines[ticker])['Close'].astype(float).pct_change() + 1).prod() - 1
returns.append(cumret)
symbols.append(ticker)

retdf = pd.DataFrame(returns, index=symbols, columns=['Return'])`
print(retdf.Return.nlargest(3))

I am getting an Error thrown for different stocks each time. Did yahoo change its site? Is there a fix for the problem?
This is the Error:
Traceback (most recent call last):
File "C:\Users\User\Desktop\Python\pythonProject\stock\test_center.py", line 53, in
klines[ticker] = yf.download(ticker.upper(), interval='1d', period=f'{days}d', threads=False)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 102, in download
data = _download_one(ticker, period=period, interval=interval,
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 181, in download_one
return Ticker(ticker).history(period=period, interval=interval,
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\base.py", line 179, in history
data = data.json()
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\json_init
.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\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)

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions