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

quarterly_earnings & get_earning not working #1948

Open
mukalaaa opened this issue May 25, 2024 · 3 comments · Fixed by #1977
Open

quarterly_earnings & get_earning not working #1948

mukalaaa opened this issue May 25, 2024 · 3 comments · Fixed by #1977

Comments

@mukalaaa
Copy link

Describe bug

I cannot get any earning data at all, I tried AAPL and other companies, I always get an error that is not implemented in yfinance. I appreciate any help about this

Simple code that reproduces your problem

import yfinance as yf

Define the ticker

ticker = '7010.SR'

Fetch the stock data

stock = yf.Ticker(ticker)

Get earnings data

earnings = stock.get_earnings()

Print earnings data

print(earnings)

Debug log

Traceback (most recent call last):
File "/Users/alan/Desktop/Investments Website Project/youtube channels ideas/earnings.py", line 10, in
earnings = stock.get_earnings()
^^^^^^^^^^^^^^^^^^^^
File "/Users/alan/Desktop/Investments Website Project/.venv/lib/python3.12/site-packages/yfinance/base.py", line 292, in get_earnings
data = self._fundamentals.earnings[freq]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alan/Desktop/Investments Website Project/.venv/lib/python3.12/site-packages/yfinance/scrapers/fundamentals.py", line 34, in earnings
raise YFNotImplementedError('earnings')
yfinance.exceptions.YFNotImplementedError: Have not implemented fetching 'earnings' from Yahoo API

Bad data proof

No response

yfinance version

yfinance-0.2.40

Python version

No response

Operating system

MacOS

@ItzXyers
Copy link

ItzXyers commented May 29, 2024

It appears that the scraper doesn't even try to provide the earnings:
(yfinance.scrapers.fundamentals; lines 11-35)

class Fundamentals:

	def __init__(self, data: YfData, symbol: str, proxy=None):
    	self._data = data
    	self._symbol = symbol
    	self.proxy = proxy
   	 
    	# Earnings are never set - which is what's causing the error.
    	self._earnings = None
    	self._financials = None
    	self._shares = None

    	self._financials_data = None
    	self._fin_data_quote = None
    	self._basics_already_scraped = False
    	self._financials = Financials(data, symbol)

	@property
	def financials(self) -> "Financials":
    	return self._financials

	@property
	def earnings(self) -> dict:
    	# And then this if statement is true, which throws the error.
    	if self._earnings is None:
        	raise YFNotImplementedError('earnings')
    	return self._earnings
...

Which means that yfinance doesn’t support getting fundamentals at all.

If you're looking for alternatives; I know that the alpha_vantage library supports getting fundamental data. You are limited to 25 api requests/day, though.

@Nela62
Copy link

Nela62 commented Jul 1, 2024

Keep in mind that Alpha Vantage has incorrect data for revenue, income, and debt

@ValueRaider
Copy link
Collaborator

Which means that yfinance doesn’t support getting fundamentals at all.

Not fair. yfinance gets income, cashflow and balance sheet. Earnings in one of those.

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 a pull request may close this issue.

4 participants