-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
earnings_date failing (KeyError: 'Earnings Date') #1932
Comments
Yahoo has changed table structure
Event name is nice addition, but losing dates a problem. Hoping for a way to get old structure. Probably Yahoo has broken their redesign rollout, because their |
Looks like yahoo fixed their problem. yfinance works fine now. I suggest you close this issue. |
I suspect it will return, I've seen this alternative table randomly rarely over last few weeks. Yahoo is up to something... |
For some tickers, it works and some others it doesn't. At this time, ENB.TO works, TSLA still gives the issue. |
It returned to normal, interesting! |
Looks like Yahoo finance's earnings tab blew up again. |
This works fine now, but it's also pulling up non-quarterly earnings. Depending on how Yahoo Finance plans to move forward with the earnings table, can we please add an option in the future to filter out the non-quarterly earnings? Right now, we can tell which ones are quarterly by the Company column: However, this column is omitted in the get_earnings function. |
Keeping column |
Having the issue starting from this week. |
As of today, some tickers work perfectly fine, some tickers give the 'Earnings Date' KeyError. |
when I tried to get the earnings of AI. https://finance.yahoo.com/calendar/earnings/?symbol=AI, yahoo may need some time to run js. I also tried selenium. It works but much slower. |
I encountered this recently. I think what happens is, when Yahoo is overloaded they use a second data provider which returns a completely different table structure. |
Did the table structure blow up again. I'm getting an error |
Yes, it is failing for me for multiple (50+) tickers (starting yesterday/last night) |
Even I'm facing the same issue. stacktraceTraceback (most recent call last): File "C:\Users\Revanth\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\indexes\base.py", line 3805, in get_loc return self._engine.get_loc(casted_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc File "pandas\\_libs\\hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\\_libs\\hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'Earnings Date'The above exception was the direct cause of the following exception: Traceback (most recent call last): |
Yeah, I'm having issues with earnings_dates too since a couple days ago |
Same, does anyone know what's going on this time? |
The data return by python request doesn't execute the filter that you would have on a browser:
This is why "Earnings Date" is not there. The javascript needs to be executed. |
Ah I'm also having this issue, tried using selenium/pyppeteer and it just recently broke like two days ago and it also gives that generic response (US User) |
@michaelmoopenn The table you quoted is the new format, it is missing "Earnings Date" column. Your link shows new format. Can you post a screenshot of successfully fetching the old format? |
If you go on the link with your browser you should see this: The issue is that python request don't get the same view as with your browser even though there is the filter attributes in the get parameters. There is some post-processing javascript that is not executed. |
I don't see that. It's not adblock etc, I turned that off. Maybe it's geo-specific - I'm Europe. |
I am North America. This one looks challenging to fix! |
So, is this gonna stay permanently returning error for EU users ? |
I'm in the US. cTicker.earnings_dates() isnt giving me anything, but cTicker.earnings_history() does. (It just doesnt show me the future earnings dates..) |
The filter works only when you are logged in. |
You're right. So probably yfinance needs to support logging in. |
I just tried logging into yahoo and it showed me the normal earnings dates, so that might be a good solution |
True, when logged in to Yahoo is works fine. |
Hi David, whereas if I used earnings_history() I get: I do see (as shown by others above) that if am not logged into yahoo then when I go to the earnings page when I am logged in to yahoo that url shows me the upcoming earnings as well as several of the past ones.. Is it that I need to somehow login to yahoo thru yfin?
|
For anyone struggling to extract the earnings from yfinance right now, I have this little snippet that got me out of trouble. It's not a drop-in replacement for yfinance, but those, like me, that needed to get the historical earnings to another platform, this might save you some trouble while this gets fixed.
const earnings_json = $$('#fin-cal-table tbody tr')
.map(tr => ({
symbol: $('td:nth-child(1)', tr).innerText,
date: new Date($('td:nth-child(3) span:nth-child(1)', tr).innerText.substring(0, 12)),
}))
.filter(e => new Date() > e.date)
.map(e => ({
...e,
date: e.date.toISOString().split('T')[0],
}))
const rows = [
["symbol", "date"],
...earnings_json.map(e => [e.symbol, e.date])
]
let csvContent = "data:text/csv;charset=utf-8," + rows.map(r => r.join(",")).join("\n")
var encodedUri = encodeURI(csvContent)
var link = document.createElement("a")
link.setAttribute("href", encodedUri)
link.setAttribute("download", `earnings_${earnings_json[0].symbol}.csv`)
link.click() You can remove the Hope this helps. |
Thank you for your answers, login in does change the data displayed as well for me (I am in EU). I guess that indeed a login method in the class YfData along with the cookies handling would be helpful if possible ? |
@szapiro - your sample somehow doesn't work for example on AAPL. There are 4 dates in 2025 listed and only 1 matches the above. |
Bad news: Yahoo is changing their layout again. Good news: there's a new URL that displays all earnings dates, hopefully a quick change for a fix. Old URL: https://finance.yahoo.com/calendar/earnings?symbol=GOOG&offset=0&size=100 (Adding the day parameter gets a different layout, that displays the whole list of earning dates.) |
Like @AlphaGit said, Yahoo changed their API route and their table formatting.
I'm not a contributor, so if you are one and you're reading this, feel free to commit this change and link this issue with your commit. As a side note, this fix only supports Eastern U.S. Time (EDT/EST) earnings dates for now. |
Great for the new URL! |
I contacted the Yahoo Finance Data support team ; they didn't seem to be aware there were any errors in their data. They said they'll check it out, I'll keeep you posted. |
I have a few examples across different symbols that we had to manually fix. Feel free to reach out if you think it would help in figuring out the source of the errors. (It's far from a complete investigation, just a few examples.) |
There are systematic errors across many different tickers on the Yahoo Finance website. Yahoo Finance devs must have changed something somewhere and didn't realize they broke anything. They should have done regression tests and they didn't. In the meantime, until they fix the error, I would suggest finding a source of data outside of Yahoo Finance (if you really need the data). |
On released earnings they looks to display: accurate earnings date - 1 day. |
Do you think it is because all date is previously in UTC format at 12am? And then that's the reason why it is -1 day and also that's why they have difference for EST and EDT? |
What's your reference for dates, I can't find a good second source to refence that includes the times. |
I get them from Zack's. Here's a link to Agilent's earnings calendar from Zacks for example. If you cross reference with the company's investor relations page on their website, you'll see that when it comes to past earnings dates, Yahoo is wrong whereas Zacks is correct. On the other hand, when it comes to future earnings data, Yahoo is correct whereas Zacks is wrong. So I get my past earnings data from Zacks but my future earnings dates from Yahoo, as a workaround until Yahoo correct their bug. |
I am not in the US, and this worked for me. I did: |
Describe bug
The earnings_dates record is not available
Simple code that reproduces your problem
import yfinance as yf
msft = yf.Ticker('MSFT')
msft.earnings_dates
Debug log
Bad data proof
No response
yfinance
versionyfinance 0.2.38
Python version
python3.10
Operating system
ubuntu
The text was updated successfully, but these errors were encountered: