4

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?

ouroboros1
  • 9,113
  • 3
  • 7
  • 26
Laurence Lam
  • 41
  • 1
  • 3
  • 1
    The error occurred because library did not receive expected result from Yahoo API. Maybe Yahoo changed its API or its service is throwing some errors. – Aidis Dec 17 '22 at 06:45

2 Answers2

1

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

fabmeyer
  • 51
  • 1
  • 6
1

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)

Anthonyj
  • 11
  • 1