famafrench.FamaFrench.comparePortfolios¶
-
FamaFrench.comparePortfolios(self, kfType, kfFreq, dt_start, dt_end, *args)[source]¶ Generalized routine used to compare datasets constructed from wrds-cloud queries to their equivalents made publicly available on Ken French’s online library at a given frequency and for a given sample period.
- Parameters
kfType (str) –
Dataset type to query. Possible choices are:
ReturnsFactorsNumFirmsCharacs
kfFreq (str) –
Observation frequency of the portfolios. Possible choices are:
D: dailyW: weeklyM: monthlyQ: quarterly (3-months)A: annual
dt_start (datetime.date) – Starting date for the dataset queried or locally retrieved.
dt_end (datetime.date) – Ending date for the dataset queried or locally retrieved.
kfDim (list, int, [optional]) – Dimensions for sorting on each element in the list
self.sortCharacsId.kfRetType (str, [optional]) –
Weighting-scheme for portfolios. Possible choices are:
vw: value-weightsew: equal-weights
- Returns
dfcorrTable (pandas.DataFrame or list, pandas.DataFrame if
len(kfDim) == 3) – Table w/ Pearson correlations between wrds-cloud constructed and Ken French online library portfolio variables at a given frequency and over a given sample period.dfmeanTable (` pandas.DataFrame` or list, pandas.DataFrame if
len(kfDim) == 3) – Table w/ mean statistics for wrds-cloud constructed and Ken French online library portfolio variables at a given frequency and over a given sample period.dfstdevTable (pandas.DataFrame or list, pandas.DataFrame if
len(kfDim) == 3) – Table w/ standard deviation statistics for wrds-cloud constructed and Ken French online library portfolio variables at a given frequency and over a given sample period.
Note
The routine is “wrapped” w/ the user-defined function
timing()from modulefamafrench.utils.py. This wrapper times (in seconds) how long the routine takes to complete.Note
Portfolios require anomaly characteristics from the last fiscal year. To get non-missing observations starting on date
dt_start, we construct portfolios using a startdate that is two/three years prior todt_start. We then slice the resulting pandas.DataFrames starting w/dt_start.