ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.99k stars 2.45k forks source link

get_earnings raises type error #1327

Open lucas03 opened 1 year ago

lucas03 commented 1 year ago

Are you up-to-date?

yes

Does Yahoo actually have the data?

No

Are you spamming Yahoo?

No

Still think it's a bug?

Delete this default message and submit your bug report here, providing the following as best you can:

    ticker = yfinance.Ticker('GLPG.AS')
    earnings = ticker.get_earnings(freq="quarterly", as_dict=True)
    print(earnings)
Traceback (most recent call last):
  File "/Users/lukasvojt/Project/digrin/test/test.py", line 48, in <module>
    earnings = ticker.get_earnings(freq="quarterly", as_dict=True)
  File "/Users/lukasvojt/Project/digrin/env/lib/python3.9/site-packages/yfinance/base.py", line 964, in get_earnings
    dict_data['financialCurrency'] = 'USD' if 'financialCurrency' not in self._earnings else self._earnings[
TypeError: argument of type 'NoneType' is not iterable

I guess self._earnings is not expected to be None by this code?

lucas03 commented 1 year ago

maybe just replace self._earnings with self._fundamentals.earnings?

suhaskashyaps commented 1 year ago

While using the stock.info['financialCurrency'] command, I am getting this error: KeyError: 'financialCurrency' Has finance changed its structure? PS: I used this same command a few months back and it was working just fine.

ValueRaider commented 1 year ago

@lucas03 Maybe submit a pull request?

@suhaskashyaps You're issue is different, you should submit a new Issue. But first double-check bug because I can't reproduce.

lucas03 commented 1 year ago

As I am not familiar with yfinance, I thought somebody would just say my random suggestion won't work because of ... I'll try pull request if I get some time for it 👍

ValueRaider commented 1 year ago

You're thinking right area. But I'd question why it's trying to add currency in first place - inspect GitHub blame, who added it and why.