Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas_datareader.yahoo.daily not working suddenly [duplicate]

One week ago, I ran the following code and did not get an error.

import datetime as dt
import pandas_datareader.yahoo.daily as yd
df1 = yd.YahooDailyReader("SPY", interval='d', start=dt.date(2022,7,1),end=dt.date.today()).read()

However, when I tried the same code today, I got the following error message:

error message

Does anyone know how to solve this problem?

like image 765
Laurence Lam Avatar asked Nov 03 '25 07:11

Laurence Lam


2 Answers

It seems yahoo finance has changed it API or the service is down.

You can use Tiingo API instead (you need to make an account to get an API token)

import pandas_datareader as web
r = web.get_data_tiingo("SPY", api_key=ENV('NEWS_TOKEN'))

see: Remote Data Access#Tiingo

like image 127
fabmeyer Avatar answered Nov 04 '25 20:11

fabmeyer


I have the same problem, yfinance is still working

import yfinance as yf

from yahoofinancials import YahooFinancials

my_data = yf.download('TSLA', start='2021-12-17', end='2022-12-17', progress=False)

like image 43
Anthonyj Avatar answered Nov 04 '25 21:11

Anthonyj