Skip to content
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

Fix: Earnings Date #2181

Closed
wants to merge 2 commits into from
Closed

Conversation

dhruvan2006
Copy link
Contributor

Fixes the date and column parsing logic when retrieving Earnings Date.

Changes

  • New method parse_earnings_dates in base.py
  • Updated url and columns
  • Rename Surprise(%) into Surprise (%) to maintain backwards compatibility

Usage

import yfinance as yf
earnings =  yf.Ticker('MSFT').earnings_dates
print(earnings)

The above should match the results from MSFT Earnings

Would appreciate feedback from someone from non EU.

Thanks for the work from #1932 and #2169

@ValueRaider
Copy link
Collaborator

Did you check open pull requests for duplication?

@dhruvan2006
Copy link
Contributor Author

Did you check open pull requests for duplication?

Yes, I did check for similar pull requests, and I mentioned #2169 in my description. I decided to open this PR because those had no further activity, and I wanted to help move the fix forward.

This is the returned table for BP.L, which demonstrates the fix. Thanks.

                            EPS Estimate  Reported EPS  Surprise(%)
Earnings Date                                                     
2025-10-27 00:00:00+00:00           NaN           NaN          NaN
2025-07-28 01:00:00+01:00           NaN           NaN          NaN
2025-05-05 01:00:00+01:00           NaN           NaN          NaN
2025-02-04 00:00:00+00:00          0.10           NaN          NaN
2024-10-29 00:00:00+00:00          0.13          0.14       0.0625
2024-07-30 01:00:00+01:00          0.16          0.17       0.0968
2024-05-07 01:00:00+01:00          0.18          0.16      -0.0914
2024-02-06 00:00:00+00:00          0.15          0.18       0.1842

@AlphaGit
Copy link

AlphaGit commented Dec 16, 2024

I tested this out (located in Canada), and while the download works fine, there's an extra row that doesn't seem quite correct in the results:

earnings_dates: pd.DataFrame = yf.Ticker("TSLA").get_earnings_dates(limit=100)
print("Earnings Dates\n", earnings_dates)
Earnings Dates
                            EPS Estimate  Reported EPS  Surprise(%)
Earnings Date
2025-10-20 20:00:00-04:00           NaN           NaN          NaN
2025-10-20 20:00:00-04:00           NaN           NaN          NaN
2025-07-20 20:00:00-04:00           NaN           NaN          NaN
2025-04-22 20:00:00-04:00           NaN           NaN          NaN
2025-01-23 19:00:00-05:00          0.74           NaN          NaN
...                                 ...           ...          ...
2011-08-02 20:00:00-04:00         -0.03         -0.04      -0.0481
2011-05-03 20:00:00-04:00         -0.03         -0.03       0.1456
2011-02-14 19:00:00-05:00         -0.03         -0.03       0.0563
2010-11-08 19:00:00-05:00         -0.03         -0.02       0.1443
NaT                                 NaN           NaN          NaN

Update: I forgot to specify which symbol I was using. This is TSLA.

@dhruvan2006
Copy link
Contributor Author

@AlphaGit Nice catch, has been fixed now. I believe this has to do with Yahoo returning a different table structure compared to before.

@AlphaGit
Copy link

Tested again with a few more assets. Works like a charm! 🎉

@Bristopher
Copy link

Bristopher commented Dec 18, 2024

Hmm this may be a noob question but I installed the branch in a venv and currently getting this error and not sure why, any ideas?

AttributeError: module 'yfinance' has no attribute 'Ticker'

Edit: was trying to install with cloning and pip install -e, instead this worked
pip install git+https://github.com/dhruvan2006/yfinance.git@fix/earnings-date

@ValueRaider
Copy link
Collaborator

Closing as duplicate #2169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants