yahooquery
yahooquery copied to clipboard
Feature Request: Additional method that retrieves only dividends
Could you provide an example on how to retrieve dividends?
I tried this function and it returns the message Cash Flow data unavailable for fb:
symbols = ['fb']
tickers = Ticker(symbols, asynchronous=True)
tickers.get_financial_data(types="CashDividendsPaid")
I tried for several tickers and the dividends were unavailable for all of them, even though with other packages like YahooFinancials I was able to retrieve it.
Thank you for the package, I believe it would be highly valuable, specially if it allows Yahoo Finance Premium users to use it to retrieve data, I saw no other package with that feature.
PS: It would be great to have a quick example in the manual for each function, the description sometimes is a little cryptic.
The reason you're not getting any data back for Facebook is because they haven't paid any dividends yet. I'm not sure what other tickers you've tried, but it seems to be working with other companies that have paid dividends:
>>> Ticker('aapl msft gs').get_financial_data('CashDividendsPaid')
asOfDate periodType CashDividendsPaid
symbol
aapl 2017-09-30 12M -1.276900e+10
aapl 2018-09-30 12M -1.371200e+10
aapl 2019-09-30 12M -1.411900e+10
aapl 2020-06-30 TTM -1.404900e+10
gs 2016-12-31 12M -1.706000e+09
gs 2017-12-31 12M -1.769000e+09
gs 2018-12-31 12M -1.810000e+09
gs 2019-12-31 12M -2.104000e+09
gs 2020-06-30 TTM -2.358000e+09
msft 2017-06-30 12M -1.184500e+10
msft 2018-06-30 12M -1.269900e+10
msft 2019-06-30 12M -1.381100e+10
msft 2020-06-30 12M -1.513700e+10
msft 2020-06-30 TTM -1.513700e+10
There's also an example of how to use the function above in the documentation: https://yahooquery.dpguthrie.com/guide/ticker/financials/#get_financial_data
Look for the example tab below the function name.
Hey @dpguthrie , thank you very much for the reply. Sorry, you are right, I tried companies like Amazon and Netflix that have never paid dividends. I was testing without thinking about it. One last thing, how to select the date range of the result? For example, Microsoft has dividend data since 2003 and it is just showing since 2017.
If you're a premium subscriber, you can retrieve that data through p_get_financial_data. Otherwise, you're limited to either the four most recent quarters or years.
>>> t = Ticker('aapl', username=<username>, password=<password>)
>>> t.p_get_financial_data('CashDividendsPaid', frequency='q', trailing=False)
asOfDate periodType CashDividendsPaid
symbol
aapl 1989-12-31 3M -1.400000e+07
aapl 1990-03-31 3M -1.350000e+07
aapl 1990-06-30 3M -1.340000e+07
aapl 1990-09-30 3M -1.290000e+07
aapl 1990-12-31 3M -1.390000e+07
aapl 1991-03-31 3M -1.410000e+07
aapl 1991-06-30 3M -1.440000e+07
aapl 1991-09-30 3M -1.410000e+07
aapl 1991-12-31 3M -1.420000e+07
aapl 1992-03-31 3M -1.450000e+07
aapl 1992-06-30 3M -1.430000e+07
aapl 1992-09-30 3M -1.420000e+07
aapl 1992-12-31 3M -1.420000e+07
aapl 1993-03-31 3M -1.350000e+07
aapl 1993-06-30 3M -1.400000e+07
aapl 1993-09-30 3M -1.390000e+07
aapl 1993-12-31 3M -1.395800e+07
aapl 1994-03-31 3M -1.404200e+07
aapl 1994-06-30 3M -1.428700e+07
aapl 1994-09-30 3M -1.428500e+07
aapl 1994-12-31 3M -1.400000e+07
aapl 1995-03-31 3M -1.500000e+07
aapl 1995-06-30 3M -1.400000e+07
aapl 1995-09-30 3M -1.500000e+07
aapl 1995-12-31 3M -1.500000e+07
aapl 1996-03-31 3M 1.000000e+06
aapl 1996-06-30 3M 0.000000e+00
aapl 1996-09-30 3M 0.000000e+00
aapl 2012-12-31 3M -2.493000e+09
aapl 2013-03-31 3M -2.491000e+09
aapl 2013-06-30 3M -2.811000e+09
aapl 2013-09-30 3M -2.769000e+09
aapl 2013-12-31 3M -2.769000e+09
aapl 2014-03-31 3M -2.661000e+09
aapl 2014-06-30 3M -2.867000e+09
aapl 2014-09-30 3M -2.829000e+09
aapl 2014-12-31 3M -2.801000e+09
aapl 2015-03-31 3M -2.743000e+09
aapl 2015-06-30 3M -3.053000e+09
aapl 2015-09-30 3M -2.964000e+09
aapl 2015-12-31 3M -2.969000e+09
aapl 2016-03-31 3M -2.902000e+09
aapl 2016-06-30 3M -3.187000e+09
aapl 2016-09-30 3M -3.092000e+09
aapl 2016-12-31 3M -3.130000e+09
aapl 2017-03-31 3M -3.004000e+09
aapl 2017-06-30 3M -3.365000e+09
aapl 2017-09-30 3M -3.270000e+09
aapl 2017-12-31 3M -3.339000e+09
aapl 2018-03-31 3M -3.190000e+09
aapl 2018-06-30 3M -3.653000e+09
aapl 2018-09-30 3M -3.530000e+09
aapl 2018-12-31 3M -3.568000e+09
aapl 2019-03-31 3M -3.443000e+09
aapl 2019-06-30 3M -3.629000e+09
aapl 2019-09-30 3M -3.479000e+09
aapl 2019-12-31 3M -3.539000e+09
aapl 2020-03-31 3M -3.375000e+09
aapl 2020-06-30 3M -3.656000e+09
Nice to know that, @dpguthrie. Should premium subscription be a necessity in this case? Because other packages can retrieve the complete dividend historical data without it. Here is an example:
from yahoofinancials import YahooFinancials
import pandas as pd
ticker = YahooFinancials("MSFT")
dividends_dict = ticker.get_daily_dividend_data(start_date="2000-01-01", end_date="2020-10-15")
pd.DataFrame(dividends_dict["MSFT"])
You're looking for dividend paid per share:
t = Ticker(symbols, asynchronous=True)
df = t.history(period='max')
if 'dividends' in df:
df[df['dividends'] != 0]['dividends']
Since you're probably not the only one looking for this data, I'll most likely create an additional method that retrieves only dividends. Look for something in the next release. In the meantime, the above should get you the data you're looking for.
Since you're probably not the only one looking for this data, I'll most likely create an additional method that retrieves only dividends. Look for something in the next release. In the meantime, the above should get you the data you're looking for.
Thanks man, I appreciate, @dpguthrie
Hey @dpguthrie , I'm reopening the issue just as a reminder, ok? Thank you