yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Stock data returns NaN’s

Open wesdevpro opened this issue 4 years ago • 8 comments

When my app calls for long periods of data- particularly One year and up - y finance returns NaN’s.

wesdevpro avatar May 06 '20 16:05 wesdevpro

Could you provide an example?

rodrigobercini avatar May 14 '20 15:05 rodrigobercini

Got a similar situation. It might be cause by a configuration issue or the environment the script is running in. In my case I only see NaNs returned in a docker deployment(python:3.7.7-slim-buster, yfinance 0.1.54). Running the same query local(Python 3.7.6,yfinance 0.1.54) doesn't cause NaNs.

symbols batch RIG MUR VTR BABA AGI BOOT UNM MIME AER IPHI OMF MRO VIPS CLR PFSI AYX CS PBR-A WYND BBD THC SWCH OCN UAL ARWR AL INSG PFE GGB CC HLX BLMN SIG ASND CABO ECPG QRTEA PBF VIRT FCX

timeframe 2015-07-01 to: 2020-05-16

with NaNs AYX GET /v8/finance/chart/AYX?period1=1435708800&period2=1589596628&interval=1d&includePrePost=False&events=div%2Csplits HTTP/1.1" 200 None

SWCH GET /v8/finance/chart/SWCH?period1=1435708800&period2=1589596515&interval=1d&includePrePost=False&events=div%2Csplits HTTP/1.1" 200 None

xcompile avatar May 16 '20 02:05 xcompile

image Here's an example of the Dow Jones Industrial. All the blank areas are NaN values.

Downloading the csv directly from Yahoo gives this: image

jrwrigh avatar Jun 23 '20 00:06 jrwrigh

I'm failing to reproduce your issue. Perhaps try to install yfinance in a fresh environment?

image

rodrigobercini avatar Jun 23 '20 14:06 rodrigobercini

I'm failing to reproduce your issue. Perhaps try to install yfinance in a fresh environment?

image

You need download a batch of tickers. Single or a small number of tickers does not trigger this issue.

GF-Huang avatar Feb 20 '21 11:02 GF-Huang

I have the same problem. It appears when downloading a lot of tickers and it randomly omits datapoints. When running the download several times and filling nan values the number of NaN decreases constantly like this df0.fillna(df1).fillna(df2) etc..

ighgusp avatar Apr 23 '21 16:04 ighgusp

I also have the same issue. When downloading historical data for one ticker at the time using ticker.history(), everything works fine and no NaN values are present. However, when I try to download data for 2 or more tickers at the time (e.g. yf.download("^OMX ^GSPC" , period = "5y", group_by = "tickers"), I end up with multiple NaN values for both series. I can't seem to find a good fix for this?

Lisok avatar Feb 08 '22 16:02 Lisok

@rodrigobercini I apologize for my lack of help with this issue as I'm very busy with college. As a quick fix in my web app, I remove any NaN values from the data. I'm not exactly sure which stocks cause this issue, nor do I know of any correlation between these stocks.

wesdevpro avatar May 02 '22 02:05 wesdevpro