@@ -578,6 +578,7 @@ def quantile_turnover(quantile_factor, quantile, period=1):
578578 Quantile on which to perform turnover analysis.
579579 period: int, optional
580580 Number of days over which to calculate the turnover.
581+
581582 Returns
582583 -------
583584 quant_turnover : pd.Series
@@ -616,14 +617,13 @@ def factor_rank_autocorrelation(factor_data, period=1):
616617 - See full explanation in utils.get_clean_factor_and_forward_returns
617618 period: int, optional
618619 Number of days over which to calculate the turnover.
620+
619621 Returns
620622 -------
621623 autocorr : pd.Series
622624 Rolling 1 period (defined by time_rule) autocorrelation of
623625 factor values.
624-
625626 """
626-
627627 grouper = [factor_data .index .get_level_values ('date' )]
628628
629629 ranks = factor_data .groupby (grouper )['factor' ].rank ()
@@ -658,17 +658,18 @@ def common_start_returns(factor,
658658 factor : pd.DataFrame
659659 DataFrame with at least date and equity as index, the columns are
660660 irrelevant
661- prices : pd.DataFrame
662- A wide form Pandas DataFrame indexed by date with assets
663- in the columns. Pricing data should span the factor
664- analysis time period plus/minus an additional buffer window
665- corresponding to after/before period parameters.
661+ returns : pd.DataFrame
662+ A wide form Pandas DataFrame indexed by date with assets in the
663+ columns. Returns data should span the factor analysis time period
664+ plus/minus an additional buffer window corresponding to after/before
665+ period parameters.
666666 before:
667667 How many returns to load before factor date
668668 after:
669669 How many returns to load after factor date
670670 cumulative: bool, optional
671- Return cumulative returns
671+ Whether or not the given returns are cumulative. If False the given
672+ returns are assumed to be daily.
672673 mean_by_date: bool, optional
673674 If True, compute mean returns for each date and return that
674675 instead of a return series for each asset
@@ -684,7 +685,6 @@ def common_start_returns(factor,
684685 Dataframe containing returns series for each factor aligned to the same
685686 index: -before to after
686687 """
687-
688688 if not cumulative :
689689 returns = returns .apply (cumulative_returns , axis = 0 )
690690
@@ -714,9 +714,6 @@ def common_start_returns(factor,
714714 series .index = range (starting_index - day_zero_index ,
715715 ending_index - day_zero_index )
716716
717- if cumulative :
718- series = (series / series .loc [0 , :]) - 1
719-
720717 if demean_by is not None :
721718 mean = series .loc [:, demean_equities ].mean (axis = 1 )
722719 series = series .loc [:, equities ]
@@ -749,11 +746,11 @@ def average_cumulative_return_by_quantile(factor_data,
749746 each period, the factor quantile/bin that factor value belongs to, and
750747 (optionally) the group the asset belongs to.
751748 - See full explanation in utils.get_clean_factor_and_forward_returns
752- prices : pd.DataFrame
753- A wide form Pandas DataFrame indexed by date with assets
754- in the columns. Pricing data should span the factor
755- analysis time period plus/minus an additional buffer window
756- corresponding to periods_after/ periods_before parameters.
749+ returns : pd.DataFrame
750+ A wide form Pandas DataFrame indexed by date with assets in the
751+ columns. Returns data should span the factor analysis time period
752+ plus/minus an additional buffer window corresponding to periods_after/
753+ periods_before parameters.
757754 periods_before : int, optional
758755 How many periods before factor to plot
759756 periods_after : int, optional
@@ -765,6 +762,7 @@ def average_cumulative_return_by_quantile(factor_data,
765762 neutral portfolio)
766763 by_group : bool
767764 If True, compute cumulative returns separately for each group
765+
768766 Returns
769767 -------
770768 cumulative returns and std deviation : pd.DataFrame
@@ -791,10 +789,15 @@ def average_cumulative_return_by_quantile(factor_data,
791789 """
792790
793791 def cumulative_return_around_event (q_fact , demean_by ):
794- return common_start_returns (q_fact , returns ,
795- periods_before ,
796- periods_after ,
797- True , True , demean_by )
792+ return common_start_returns (
793+ q_fact ,
794+ returns ,
795+ periods_before ,
796+ periods_after ,
797+ cumulative = True ,
798+ mean_by_date = True ,
799+ demean_by = demean_by ,
800+ )
798801
799802 def average_cumulative_return (q_fact , demean_by ):
800803 q_returns = cumulative_return_around_event (q_fact , demean_by )
0 commit comments