mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 04:31:13 +00:00
Add divs chart to sdk (#3529)
* add divs chart to sdk * add examples * fix tests * fix tests * fix test Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
@@ -433,7 +433,7 @@ stocks.fa.quote,openbb_terminal.stocks.fundamental_analysis.fmp_model.get_quote,
|
||||
stocks.fa.score,openbb_terminal.stocks.fundamental_analysis.fmp_model.get_score,
|
||||
stocks.fa.data,openbb_terminal.stocks.fundamental_analysis.finviz_model.get_data,
|
||||
stocks.fa.cal,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_model.get_calendar_earnings,
|
||||
stocks.fa.divs,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_model.get_dividends,
|
||||
stocks.fa.divs,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_model.get_dividends,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_view.display_dividends
|
||||
stocks.fa.hq,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_model.get_hq,
|
||||
stocks.fa.info,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_model.get_info,
|
||||
stocks.fa.mktcap,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_model.get_mktcap,openbb_terminal.stocks.fundamental_analysis.yahoo_finance_view.display_mktcap
|
||||
|
||||
|
@@ -265,8 +265,22 @@ def get_dividends(symbol: str) -> pd.DataFrame:
|
||||
-------
|
||||
pd.DataFrame
|
||||
Dataframe of dividends and dates
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from openbb_terminal.sdk import openbb
|
||||
>>> openbb.fa.divs("AAPL")
|
||||
"""
|
||||
return pd.DataFrame(yf.Ticker(symbol).dividends)
|
||||
df = pd.DataFrame(yf.Ticker(symbol).dividends)
|
||||
|
||||
if df.empty:
|
||||
console.print("No dividends found.\n")
|
||||
return pd.DataFrame()
|
||||
|
||||
df["Change"] = df.diff()
|
||||
df = df[::-1]
|
||||
|
||||
return df
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
|
||||
@@ -185,11 +185,12 @@ def display_calendar_earnings(symbol: str, export: str = ""):
|
||||
def display_dividends(
|
||||
symbol: str,
|
||||
limit: int = 12,
|
||||
plot: bool = False,
|
||||
plot: bool = True,
|
||||
export: str = "",
|
||||
external_axes: Optional[List[plt.Axes]] = None,
|
||||
):
|
||||
"""Display historical dividends
|
||||
|
||||
Parameters
|
||||
----------
|
||||
symbol: str
|
||||
@@ -202,15 +203,17 @@ def display_dividends(
|
||||
Format to export data
|
||||
external_axes : Optional[List[plt.Axes]], optional
|
||||
External axes (1 axis is expected in the list), by default None
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from openbb_terminal.sdk import openbb
|
||||
>>> openbb.fa.divs_chart("AAPL")
|
||||
"""
|
||||
div_history = yahoo_finance_model.get_dividends(symbol)
|
||||
if div_history.empty:
|
||||
console.print("No dividends found.\n")
|
||||
return
|
||||
div_history["Dif"] = div_history.diff()
|
||||
div_history = div_history[::-1]
|
||||
if plot:
|
||||
|
||||
if plot:
|
||||
# This plot has 1 axis
|
||||
if not external_axes:
|
||||
_, ax = plt.subplots(figsize=plot_autoscale(), dpi=PLOT_DPI)
|
||||
@@ -231,7 +234,7 @@ def display_dividends(
|
||||
alpha=1,
|
||||
label="Dividends Payout",
|
||||
)
|
||||
ax.set_ylabel("Amount ($)")
|
||||
ax.set_ylabel("Amount Paid ($)")
|
||||
ax.set_title(f"Dividend History for {symbol}")
|
||||
ax.set_xlim(div_history.index[-1], div_history.index[0])
|
||||
ax.legend()
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
Date,Dividends
|
||||
1987-05-11,0.000536
|
||||
1987-08-10,0.000536
|
||||
1987-11-17,0.000714
|
||||
1988-02-12,0.000714
|
||||
1988-05-16,0.000714
|
||||
1988-08-15,0.000714
|
||||
1988-11-21,0.000893
|
||||
1989-02-17,0.000893
|
||||
1989-05-22,0.000893
|
||||
1989-08-21,0.000893
|
||||
1989-11-17,0.000982
|
||||
1990-02-16,0.000982
|
||||
1990-05-21,0.000982
|
||||
1990-08-20,0.000982
|
||||
1990-11-16,0.001071
|
||||
1991-02-15,0.001071
|
||||
1991-05-20,0.001071
|
||||
1991-08-19,0.001071
|
||||
1991-11-18,0.001071
|
||||
1992-02-14,0.001071
|
||||
1992-06-01,0.001071
|
||||
1992-08-17,0.001071
|
||||
1992-11-30,0.001071
|
||||
1993-02-12,0.001071
|
||||
1993-05-28,0.001071
|
||||
1993-08-16,0.001071
|
||||
1993-11-19,0.001071
|
||||
1994-02-07,0.001071
|
||||
1994-05-27,0.001071
|
||||
1994-08-15,0.001071
|
||||
1994-11-18,0.001071
|
||||
1995-02-13,0.001071
|
||||
1995-05-26,0.001071
|
||||
1995-08-16,0.001071
|
||||
1995-11-21,0.001071
|
||||
2012-08-09,0.094643
|
||||
2012-11-07,0.094643
|
||||
2013-02-07,0.094643
|
||||
2013-05-09,0.108929
|
||||
2013-08-08,0.108929
|
||||
2013-11-06,0.108929
|
||||
2014-02-06,0.108929
|
||||
2014-05-08,0.1175
|
||||
2014-08-07,0.1175
|
||||
2014-11-06,0.1175
|
||||
2015-02-05,0.1175
|
||||
2015-05-07,0.13
|
||||
2015-08-06,0.13
|
||||
2015-11-05,0.13
|
||||
2016-02-04,0.13
|
||||
2016-05-05,0.1425
|
||||
2016-08-04,0.1425
|
||||
2016-11-03,0.1425
|
||||
2017-02-09,0.1425
|
||||
2017-05-11,0.1575
|
||||
2017-08-10,0.1575
|
||||
2017-11-10,0.1575
|
||||
2018-02-09,0.1575
|
||||
2018-05-11,0.1825
|
||||
2018-08-10,0.1825
|
||||
2018-11-08,0.1825
|
||||
2019-02-08,0.1825
|
||||
2019-05-10,0.1925
|
||||
2019-08-09,0.1925
|
||||
2019-11-07,0.1925
|
||||
2020-02-07,0.1925
|
||||
2020-05-08,0.205
|
||||
2020-08-07,0.205
|
||||
2020-11-06,0.205
|
||||
2021-02-05,0.205
|
||||
2021-05-07,0.22
|
||||
2021-08-06,0.22
|
||||
2021-11-05,0.22
|
||||
2022-02-04,0.22
|
||||
2022-05-06,0.23
|
||||
Date,Dividends,Change
|
||||
2022-05-06,0.23,0.010000000000000009
|
||||
2022-02-04,0.22,0.0
|
||||
2021-11-05,0.22,0.0
|
||||
2021-08-06,0.22,0.0
|
||||
2021-05-07,0.22,0.015000000000000013
|
||||
2021-02-05,0.205,0.0
|
||||
2020-11-06,0.205,0.0
|
||||
2020-08-07,0.205,0.0
|
||||
2020-05-08,0.205,0.012499999999999983
|
||||
2020-02-07,0.1925,0.0
|
||||
2019-11-07,0.1925,0.0
|
||||
2019-08-09,0.1925,0.0
|
||||
2019-05-10,0.1925,0.010000000000000009
|
||||
2019-02-08,0.1825,0.0
|
||||
2018-11-08,0.1825,0.0
|
||||
2018-08-10,0.1825,0.0
|
||||
2018-05-11,0.1825,0.024999999999999994
|
||||
2018-02-09,0.1575,0.0
|
||||
2017-11-10,0.1575,0.0
|
||||
2017-08-10,0.1575,0.0
|
||||
2017-05-11,0.1575,0.015000000000000013
|
||||
2017-02-09,0.1425,0.0
|
||||
2016-11-03,0.1425,0.0
|
||||
2016-08-04,0.1425,0.0
|
||||
2016-05-05,0.1425,0.012499999999999983
|
||||
2016-02-04,0.13,0.0
|
||||
2015-11-05,0.13,0.0
|
||||
2015-08-06,0.13,0.0
|
||||
2015-05-07,0.13,0.012500000000000011
|
||||
2015-02-05,0.1175,0.0
|
||||
2014-11-06,0.1175,0.0
|
||||
2014-08-07,0.1175,0.0
|
||||
2014-05-08,0.1175,0.008570999999999995
|
||||
2014-02-06,0.108929,0.0
|
||||
2013-11-06,0.108929,0.0
|
||||
2013-08-08,0.108929,0.0
|
||||
2013-05-09,0.108929,0.014285999999999993
|
||||
2013-02-07,0.094643,0.0
|
||||
2012-11-07,0.094643,0.0
|
||||
2012-08-09,0.094643,0.093572
|
||||
1995-11-21,0.001071,0.0
|
||||
1995-08-16,0.001071,0.0
|
||||
1995-05-26,0.001071,0.0
|
||||
1995-02-13,0.001071,0.0
|
||||
1994-11-18,0.001071,0.0
|
||||
1994-08-15,0.001071,0.0
|
||||
1994-05-27,0.001071,0.0
|
||||
1994-02-07,0.001071,0.0
|
||||
1993-11-19,0.001071,0.0
|
||||
1993-08-16,0.001071,0.0
|
||||
1993-05-28,0.001071,0.0
|
||||
1993-02-12,0.001071,0.0
|
||||
1992-11-30,0.001071,0.0
|
||||
1992-08-17,0.001071,0.0
|
||||
1992-06-01,0.001071,0.0
|
||||
1992-02-14,0.001071,0.0
|
||||
1991-11-18,0.001071,0.0
|
||||
1991-08-19,0.001071,0.0
|
||||
1991-05-20,0.001071,0.0
|
||||
1991-02-15,0.001071,0.0
|
||||
1990-11-16,0.001071,8.899999999999989e-05
|
||||
1990-08-20,0.000982,0.0
|
||||
1990-05-21,0.000982,0.0
|
||||
1990-02-16,0.000982,0.0
|
||||
1989-11-17,0.000982,8.9e-05
|
||||
1989-08-21,0.000893,0.0
|
||||
1989-05-22,0.000893,0.0
|
||||
1989-02-17,0.000893,0.0
|
||||
1988-11-21,0.000893,0.00017900000000000001
|
||||
1988-08-15,0.000714,0.0
|
||||
1988-05-16,0.000714,0.0
|
||||
1988-02-12,0.000714,0.0
|
||||
1987-11-17,0.000714,0.000178
|
||||
1987-08-10,0.000536,0.0
|
||||
1987-05-11,0.000536,
|
||||
|
||||
|
@@ -1,14 +0,0 @@
|
||||
Dividends Dif
|
||||
Date
|
||||
2022-06-30 1.25 0.00
|
||||
2022-03-23 1.25 0.00
|
||||
2021-12-22 1.25 0.00
|
||||
2021-09-28 1.25 0.05
|
||||
2021-06-24 1.20 0.00
|
||||
2021-03-19 1.20 0.00
|
||||
2020-12-22 1.20 0.00
|
||||
2020-09-23 1.20 0.03
|
||||
2020-06-19 1.17 0.00
|
||||
2020-03-20 1.17 0.00
|
||||
2019-12-18 1.17 0.00
|
||||
2019-09-24 1.17 0.03
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
No dividends found.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user