JECSand / yahoofinancials

A powerful financial data module used for pulling data from Yahoo Finance. This module can pull fundamental and technical data for stocks, indexes, currencies, cryptos, ETFs, Mutual Funds, U.S. Treasuries, and commodity futures.
https://pypi.python.org/pypi/yahoofinancials
MIT License
899 stars 214 forks source link

get_financial_stmts returns nothing #73

Closed eyalk5 closed 1 year ago

eyalk5 commented 4 years ago

from yahoofinancials import YahooFinancials as YF tick = YF('MSFT') tick.get_financial_stmts('quarterly', 'balance')

In[8]: tick.get_financial_stmts('quarterly', 'balance') Out[8]: {'balanceSheetHistoryQuarterly': {'MSFT': None}}

bluusun commented 4 years ago

Same issue on Mac OSX, python3.7. Installation via pip3.

eyalk5 commented 4 years ago

See solution here https://github.com/ranaroussi/yfinance/issues/291

dalder1 commented 4 years ago

@eyalk5 could you explain how to implement this change for yahoofinancials. I do not see a base.py from yahoofinancials, where should I make the recommended changes.

madis commented 4 years ago

I patched it to use yfinance in Clojure via https://github.com/clj-python/libpython-clj but it'll work for Python too like this: You'll have to change the location of your yfinance module folder:

patch ~/anaconda3/envs/panthera/lib/python3.7/site-packages/yfinance/base.py < patches/yfinance_base.patch

The below code is stored in patches/yfinance_base.patch

--- a/yfinance/base.py
+++ b/yfinance/base.py
@@ -280,8 +280,8 @@ class TickerBase():
         data = utils.get_json(url, proxy)

         # holders
-        url = "{}/{}/holders".format(self._scrape_url, self.ticker)
-        holders = _pd.read_html(url)
+        urlH = "{}/{}/holders".format(self._scrape_url, self.ticker)
+        holders = _pd.read_html(urlH)
         self._major_holders = holders[0]
         self._institutional_holders = holders[1]
         if 'Date Reported' in self._institutional_holder

I'm not that familiar with python interpreter so I just restarted the REPL process and it worked after. Probably there are simpler ways to reload the code.

user=> (require-python '[yfinance :as yf :reload])
:ok
user=> (get-attr (yf/Ticker "MSFT") :financials)
                                         2019-06-30  2018-06-30  2017-06-30  2016-06-30
Research Development                     1.6876e+10  1.4726e+10  1.3037e+10  1.1988e+10
Effect Of Accounting Charges                   None        None        None        None
Income Before Tax                        4.3688e+10  3.6474e+10  2.9901e+10  2.5639e+10
Minority Interest                              None        None        None        None
Net Income                                3.924e+10  1.6571e+10  2.5489e+10  2.0539e+10
Selling General Administrative           2.3098e+10  2.2223e+10  1.9942e+10  1.9198e+10
Gross Profit                             8.2933e+10  7.2007e+10   6.231e+10  5.8374e+10
Ebit                                     4.2959e+10  3.5058e+10  2.9331e+10  2.7188e+10
Operating Income                         4.2959e+10  3.5058e+10  2.9331e+10  2.7188e+10
Other Operating Expenses                       None        None        None        None
Interest Expense                         -2.686e+09  -2.733e+09  -2.222e+09  -1.243e+09
Extraordinary Items                            None        None        None        None
Non Recurring                                  None        None        None        None
Other Items                                    None        None        None        None
Income Tax Expense                        4.448e+09  1.9903e+10   4.412e+09     5.1e+09
Total Revenue                           1.25843e+11  1.1036e+11  9.6571e+10  9.1154e+10
Total Operating Expenses                 8.2884e+10  7.5302e+10   6.724e+10  6.3966e+10
Cost Of Revenue                           4.291e+10  3.8353e+10  3.4261e+10   3.278e+10
Total Other Income Expense Net             7.29e+08   1.416e+09     5.7e+08  -1.549e+09
Discontinued Operations                        None        None        None        None
Net Income From Continuing Ops            3.924e+10  1.6571e+10  2.5489e+10  2.0539e+10
Net Income Applicable To Common Shares    3.924e+10  1.6571e+10  2.5489e+10  2.0539e+10
dalder1 commented 4 years ago

Okay I understand what you did, but I’m still not sure how to make this work for yahoofinancials. There’s no base.py or yfinance library in my yahoofinancials directory.

sylvandb commented 4 years ago

I don't understand how or why renaming a variable (url to urlH) would fix this issue with the yahoo pages. Perhaps a different patch was significant?