55
66from .macro import Inflation
77from .common .helpers import Float , Frame , Date , Index
8- # from .common._decorators import doc
98from .settings import default_ticker , PeriodLength , _MONTHS_PER_YEAR
109from .api .data_queries import QueryData
1110from .api .namespaces import get_assets_namespaces
@@ -614,8 +613,7 @@ def describe(self, years: Tuple[int, ...] = (1, 5, 10), tickers: bool = True) ->
614613 @property
615614 def mean_return (self ) -> pd .Series :
616615 """
617- TODO: Finish description
618- Calculate mean return (arithmetic mean) for the assets.
616+ Calculate annualized mean return (arithmetic mean) for the assets.
619617 """
620618 df = self ._add_inflation ()
621619 mean = df .mean ()
@@ -624,7 +622,9 @@ def mean_return(self) -> pd.Series:
624622 @property
625623 def real_mean_return (self ) -> pd .Series :
626624 """
627- Calculates real mean return (arithmetic mean) for the assets.
625+ Calculates annualized real mean return (arithmetic mean) for the assets.
626+
627+ Real rate of return is adjusted for inflation.
628628 """
629629 if hasattr (self , 'inflation' ):
630630 df = pd .concat ([self .ror , self .inflation_ts ], axis = 1 , join = 'inner' , copy = 'false' )
@@ -635,6 +635,9 @@ def real_mean_return(self) -> pd.Series:
635635 return (1. + ror_mean ) / (1. + infl_mean ) - 1.
636636
637637 def _get_asset_dividends (self , tick , remove_forecast = True ) -> pd .Series :
638+ """
639+ Get dividend time series for a single symbol.
640+ """
638641 first_period = pd .Period (self .first_date , freq = 'M' )
639642 first_day = first_period .to_timestamp (how = 'Start' )
640643 last_period = pd .Period (self .last_date , freq = 'M' )
@@ -649,6 +652,11 @@ def _get_asset_dividends(self, tick, remove_forecast=True) -> pd.Series:
649652 return s .add (pad_s , fill_value = 0 )
650653
651654 def _get_dividends (self , remove_forecast = True ) -> pd .DataFrame :
655+ """
656+ Get dividend time series for all assets.
657+
658+ If remove_forecast=True all forecasted (future) data is removed from time series.
659+ """
652660 if self ._dividends_ts .empty :
653661 dic = {}
654662 for tick in self .symbols :
@@ -660,9 +668,11 @@ def _get_dividends(self, remove_forecast=True) -> pd.DataFrame:
660668 @property
661669 def dividend_yield (self ) -> pd .DataFrame :
662670 """
663- Calculate last twelve months (LTM) dividend yield time series monthly.
664- Calculates yield assuming original asset currency (not adjusting to AssetList currency).
671+ Calculate last twelve months (LTM) dividend yield time series (monthly) for each asset.
672+
673+ All yields are calculated in the original asset currency (not adjusting to AssetList currency).
665674 Forecast dividends are removed.
675+ Zero value time series are created for assets without dividends.
666676 """
667677 if self ._dividend_yield .empty :
668678 frame = {}
@@ -701,14 +711,16 @@ def dividend_yield(self) -> pd.DataFrame:
701711 @property
702712 def dividends_annual (self ) -> pd .DataFrame :
703713 """
704- Time series of dividends for a calendar year .
714+ Return calendar year dividends time series for each asset .
705715 """
706716 return self ._get_dividends ().resample ('Y' ).sum ()
707717
708718 @property
709719 def dividend_growing_years (self ) -> pd .DataFrame :
710720 """
711- Returns the number of growing dividend years for each asset.
721+ Return the number of growing dividend years for each asset.
722+
723+ TODO: finish description. Insert an example
712724 """
713725 div_growth = self .dividends_annual .pct_change ()[1 :]
714726 df = pd .DataFrame ()
@@ -723,7 +735,7 @@ def dividend_growing_years(self) -> pd.DataFrame:
723735 @property
724736 def dividend_paying_years (self ) -> pd .DataFrame :
725737 """
726- Returns the number of years of consecutive dividend payments.
738+ Return the number of years of consecutive dividend payments for each asset .
727739 """
728740 div_annual = self .dividends_annual
729741 frame = pd .DataFrame ()
@@ -738,7 +750,7 @@ def dividend_paying_years(self) -> pd.DataFrame:
738750
739751 def get_dividend_mean_growth_rate (self , period = 5 ) -> pd .Series :
740752 """
741- Calculates geometric mean of dividends growth rate time series for a certain period.
753+ Calculate geometric mean of dividends growth rate time series for a given period.
742754 Period should be integer and not exceed the available data period_length.
743755 """
744756 if period > self .pl .years or not isinstance (period , int ):
0 commit comments