-
Notifications
You must be signed in to change notification settings - Fork 128
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
get_earnings_for_date() Always Fails Now #95
Comments
Yes, it's the same root cause as this: #94 Yahoo made a change and is returning an encrypted string for the "stores" value now instead of a plain text dictionary. Here's the workaround I'm using successfully, which is based on the fix yfinance used for the same issue. (ranaroussi/yfinance#1253) 1. Edit the stock_info.py file from yahoo_fin (...\Lib\site-packages\yahoo_fin\stock_info.py) 2. Add the following imports and install them in your project with pip if necessary
3. Edit the get_earnings_for_date() function
4. Add the following function:
|
Thank you for the workaround solution. |
Yep, yahoo made another change to encryption. Best to find an alternate project if you can (yfinance etc.). I need the get_earnings_for_date() function which is not available on yfinance so I'm stuck for now. Fortunately the yfinance project seems to be keeping up with the encryption changes so you can always go there to get the latest workaround: https://github.com/ranaroussi/yfinance/blob/main/yfinance/data.py Below is the updated decryption function I'm using. Note they changed the function name from "decrypt_cryptojs_aes" to "decrypt_cryptojs_aes_stores" so you'll need to update your call. Also need change your imports section. importsimport requests usePycryptodome = Trueif usePycryptodome: try:
updated decryption functiondef decrypt_cryptojs_aes_stores(data):
|
When I looked at yfinance, it seemed that the Earnings data was on a per symbol basis, is that correct? Just as a side note, I see that alphavantage.co API has an earnings API call, which works and is free, however I'm still keen to continue using yahoo_fin or yfinance if possible, as I don't know where the Alphavantage data is sourced, or how reliable it is. I use it to get earnings data, such as EPS and that has been quite good so far. Thanks for updating us here, I wonder if it's worth submitting a Pull Request? |
Yes, I think so. @sonso-1
Yes, I'm in the same boat.
I just tried and it doesn't seem to work. Did you get it working? Thanks! |
It's not working for me either. I'm getting "Exception: yfinance failed to decrypt Yahoo data response" I think they will fix this eventually over at yfinance. If you need earnings by date specifically, there is a pull request over there for this (ranaroussi/yfinance#1316) although I don't think it's been merged in yet, not sure. Also might want to take a look here: https://github.com/ranaroussi/yfinance/compare/1019efda61ad87b8183c2e26bd80f85035e0010f..0c037ddd128f3ce5dee79ceb8a8571e5000fcd30 I copied/pasted the "get_earnings_by_date" and "_get_earnings_by_date" functions into my project and modified to fit my needs. Not pretty but it gets the job done for now. |
My daily script suddenly started failing yesterday in here:
it appears stores is expected to be a dict, but instead it's coming back as a string.
That causes the next line which tries to use stores as a dict to fail:
so I'm guessing Yahoo has changed the underlying data format . . .
The text was updated successfully, but these errors were encountered: