famafrench.FamaFrench.getPortfolios

FamaFrench.getPortfolios(self, portLevel, factorsBool, freq, dt_start, dt_end, *args)[source]

Generalized routine used to construct datasets containing portfolio returns (which may include factor returns), number of firms in each portfolio, or average anomaly portfolio characteristics at a given frequency and for a given sample period. See subroutines for more details.

Parameters
  • portLevel (str) –

    Dataset type to construct. Possible choices are:

    • Returns

    • NumFirms

    • Characs

  • factorsBool (bool) –

    Flag for choosing whether to construct Fama-French factors or not. If True, then portLevel must be one of the following: Returns, NumFirms. Otherwise, it must be one of the following:

    • Returns

    • NumFirms

    • Characs

  • freq (str) –

    Observation frequency of the portfolios. Possible choices are:

    • D : daily

    • W : weekly

    • M : monthly

    • Q : 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.

  • dim (list, int, [optional]) – Dimensions for sorting on each element in the list idList. For example, if idList = ['ME', 'BM'] and dim = [5, 5], then the portfolio sorting strategy is characterized by a bivariate quintile sort on both size and book-to-market.

  • retType (str, [optional]) –

    Weighting-scheme for portfolios. Possible choices are:

    • vw : value-weights

    • ew : equal-weights

Returns

portTable – Dataset(s) w/ portfolio returns (which may include factor returns), number of firms in each portfolio, or average anomaly portfolio characteristics observed at frequency freq over sample period from dt_start to dt_end for a given portfolio sorting strategy.

Return type

pandas.DataFrame, or dict, pandas.DataFrame