Search code examples
pythonstockyfinance

Why is yfinance suddenly giving back empty lists for previously functioning code?


I wrote a simple script that pulled some information on a list of tickers from the yahoo api using the yfinance python module. This used to work and I could download and save relevant information on all tickers like historic prices, earnings reports, P/E, symbol, name, dividend, etc.

When I tried running the script today (which I do at regular intervals) all I got from yfinance were empty lists for all requests. As example we could take the code below: input:

import pandas as pd
import numpy as np
import yfinance as yf

test = yf.Ticker("FB")
test.history()

output:

- FB: No data found, symbol may be delisted
Out[6]: 
Empty DataFrame
Columns: [Open, High, Low, Close, Adj Close, Volume]
Index: []

This happens for all Tickers regardless (AAPL; AMZN; META; etc.) Typically I make around 2000 requests over some 3 Hour period which has been fine for the last weeks. After not running it for approx. 1 week it does not work anymore though.

Is this just yfinance having some data or api problems or am I missing something? Naturally restarting the kernel or re-installing / upgrading the yfinance module did not work.

I tried:

  • restarted kernel
  • upgraded yfinance using pip
  • uninstalled and re-installed yfinance using pip
  • deactivated antivirus
  • checking different functions (history, info, earnings, ...)

Solution

  • I tried to run the code in a jupyter notebook and it worked, so there had to be something wrong locally. I solved it by restarting the computer and re-installing yfinance both over cmd and anaconda (which seems to have done the trick)