Skip to content

Commit

Permalink
feat: add assets_dividends_yield to Portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
chilango74 committed Dec 13, 2023
1 parent 16848f1 commit 4281348
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions okama/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,50 @@ def dividend_yield(self) -> pd.Series:
div_yield_series.rename(self.symbol, inplace=True)
return div_yield_series

@property
def assets_dividend_yield(self):
"""
Calculate last twelve months (LTM) dividend yield time series (monthly) for each asset.
LTM dividend yield is the sum trailing twelve months of common dividends per share divided by
the current price per share.
All yields are calculated in the asset list base currency after adjusting the dividends and price time series.
Forecasted (future) dividends are removed.
Zero value time series are created for assets without dividends.
Returns
-------
DataFrame
Monthly time series of LTM dividend yield for each asset.
See Also
--------
dividend_yield_annual : Calendar year dividend yield time series.
dividends_annual : Calendar year dividends time series.
dividend_paying_years : Number of years of consecutive dividend payments.
dividend_growing_years : Number of years when the annual dividend was growing.
get_dividend_mean_yield : Arithmetic mean for annual dividend yield.
get_dividend_mean_growth_rate : Geometric mean of annual dividends growth rate.
Examples
--------
>>> x = ok.AssetList(['T.US', 'XOM.US'], first_date='1984-01', last_date='1994-12')
>>> x.dividend_yield
T.US XOM.US
1984-01 0.000000 0.000000
1984-02 0.000000 0.002597
1984-03 0.002038 0.002589
1984-04 0.001961 0.002346
... ...
1994-09 0.018165 0.012522
1994-10 0.018651 0.011451
1994-11 0.018876 0.012050
1994-12 0.019344 0.011975
[132 rows x 2 columns]
"""
return super()._assets_dividend_yield

@property
def real_mean_return(self) -> float:
"""
Expand Down

0 comments on commit 4281348

Please sign in to comment.