Closed NayrusLove closed 1 day ago
Duplicate #1932
Happens to me too. getting following error: yfinance 0.2.50 Debian 11 5.10.0-33-amd64 Python 3.9.2
KeyError: 'Earnings Date'
Traceback (most recent call last): File "/home/XX/.local/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3790, in get_loc return self._engine.get_loc(casted_key) File "index.pyx", line 152, in pandas._libs.index.IndexEngine.get_loc File "index.pyx", line 181, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'Earnings Date'
Indeed not working. Same issue here. Error message: KeyError: 'Earnings Date'
Traceback (most recent call last): File "C:\Users\me\Můj disk\personal stuff\programming - own code\python\options-trader v3\venv\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):
File "C:\Users\me\Můj disk\personal stuff\programming - own code\python\options-trader v3\yfinance_downloader\yfinance_handler.py", line 56, in
This is still an issue. Why is this closed? I updated yfinance, still same earnings date errors listed herein. I updated all packages to be sure, because stranger combinations hav3e certainly occured to me. Same issue. Anyone see this actually working since update two days ago?
Describe bug
I'm looking for upcoming earnings date to see if a company has an upcoming within the next 45 days. I'm getting an error any which way I attempt to gather this data. I've tried using earnings and calendar but each one returns an error. Feel free to run this for any company that has upcoming earnings date on the calendar.
Simple code that reproduces your problem
(
python ...
) import yfinance as yf from datetime import datetime, timedelta import pandas as pddef check_upcoming_earnings(ticker_symbol, days=45): """ Checks if the given stock ticker has an upcoming earnings date within the next 'days' days.
def main(): """ Main function to prompt user input and display upcoming earnings information. """ ticker_symbol = input("Enter the stock ticker symbol: ").upper().strip()
if name == "main": main() (
python ...
)Debug log
Enter the stock ticker symbol: EXAI 2024-11-20 10:27:02,260 - main - DEBUG - User entered ticker symbol: EXAI 2024-11-20 10:27:02,260 - main - DEBUG - Initializing yfinance Ticker for symbol: EXAI 2024-11-20 10:27:02,260 - main - DEBUG - Fetching earnings dates using get_earnings_dates() 2024-11-20 10:27:02,260 - yfinance - DEBUG - Entering get_earnings_dates() 2024-11-20 10:27:02,260 - yfinance - DEBUG - Entering get() 2024-11-20 10:27:02,260 - yfinance - DEBUG - Entering _make_request() 2024-11-20 10:27:02,260 - yfinance - DEBUG - url=https://finance.yahoo.com/calendar/earnings?symbol=EXAI&offset=0&size=12 2024-11-20 10:27:02,260 - yfinance - DEBUG - params=None 2024-11-20 10:27:02,260 - yfinance - DEBUG - Entering _get_cookie_and_crumb() 2024-11-20 10:27:02,260 - yfinance - DEBUG - cookie_mode = 'basic' 2024-11-20 10:27:02,260 - yfinance - DEBUG - Entering _get_cookie_and_crumb_basic() 2024-11-20 10:27:02,264 - peewee - DEBUG - ('CREATE TABLE IF NOT EXISTS "_cookieschema" ("strategy" VARCHAR(255) NOT NULL PRIMARY KEY, "fetch_date" DATETIME NOT NULL, "cookie_bytes" BLOB NOT NULL) WITHOUT ROWID', []) 2024-11-20 10:27:02,264 - peewee - DEBUG - ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0]) 2024-11-20 10:27:02,265 - yfinance - DEBUG - loaded persistent cookie 2024-11-20 10:27:02,265 - yfinance - DEBUG - reusing cookie 2024-11-20 10:27:02,272 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): query1.finance.yahoo.com:443 2024-11-20 10:27:02,373 - urllib3.connectionpool - DEBUG - https://query1.finance.yahoo.com:443 "GET /v1/test/getcrumb HTTP/11" 200 11 2024-11-20 10:27:02,373 - yfinance - DEBUG - crumb = 'NB5HqDMLc1K' 2024-11-20 10:27:02,373 - yfinance - DEBUG - Exiting _get_cookie_and_crumb_basic() 2024-11-20 10:27:02,373 - yfinance - DEBUG - Exiting _get_cookie_and_crumb() 2024-11-20 10:27:02,374 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): finance.yahoo.com:443 2024-11-20 10:27:09,597 - urllib3.connectionpool - DEBUG - https://finance.yahoo.com:443 "GET /calendar/earnings?symbol=EXAI&offset=0&size=12&crumb=NB5HqDMLc1K HTTP/11" 200 1129240 2024-11-20 10:27:09,768 - yfinance - DEBUG - response code=200 2024-11-20 10:27:09,768 - yfinance - DEBUG - Exiting _make_request() 2024-11-20 10:27:09,769 - yfinance - DEBUG - Exiting get() 2024-11-20 10:27:09,826 - main - ERROR - An unexpected error occurred while fetching earnings dates: 'Earnings Date'
❌ EXAI does not have an upcoming earnings date within the next 45 days or the data is unavailable. 2024-11-20 10:27:09,827 - main - INFO - No upcoming earnings dates found for EXAI within the next 45 days. venvdaniel@macbookpro las-fund %
Bad data proof
No response
yfinance
version0.2.50
Python version
Python 3.13.0
Operating system
Mac OS 15.1