yfinance
yfinance copied to clipboard
How to stop yfinance from giving me back a row with empty NaN values?
Greetings,
is there a reason why sometimes when I use a bulk download, such as
data = pdr.get_data_yahoo(tickers, start= weeks52, end=today)
I get a row of data with NaN values? I understand that yfinance only updates closing data. I have never had to deal with NaN row from yfinance so im a little bewildered.
Usually yfinance only returns back the most recent market data that is available. This hasn't caused me any trouble in the passed except for today... I've also noticed that this only appears to be an issue when I download data for multiple tickers. The ticker
variable above is a list of 500 stocks.
How can this be solved from my end? I know this is not too big of an issue as I can just ignore the row with NaN values. But I'm automating a program that assumes the dataframe index position for most recent data will always be the same.
Anyone else experiencing something similar?
In my case for some tickers it also returns this line, but even with 2-3 rows of data.
This is a BUG. Nobody to fix it. Even if there is PR, it is never merged. 👎
has this issue been solved?
This seems to happen when I request options data too. It is intermittent.
It seems like this library is not being actively maintained.
Here are some options:
- Identify the problem, create a PR, solve the problem, then contact the owner of this repo to request a merge.
- Work around the bug (not optimal I know but what else can you do?)
- Use a different Python library/API to achieve your goal.
When using history function with start/end parameter , the last date return NaN , the trick is to have "endDay+1" and ignore last row... its not optimized because it require to pre-process date but does perfectly fine. If you use your "end" date that return Nan value , as a "start" in another case , it will have a value.
My timezone fixes should resolve this issue, which I will personally merge in soon once it's been sufficiently tested. https://github.com/ranaroussi/yfinance/pull/1048