famafrench.FamaFrench.kfLibrary

FamaFrench.kfLibrary(self, kfType, kfFreq, dt_start, dt_end, *args, printkfName=False)[source]

Generalized routine used to query datasets from Ken French’s online library at a given frequency and for a given sample period. See subroutines for more details.

Parameters
  • kfType (str) –

    Dataset type to query. Possible choices are:

    • Returns

    • Factors

    • NumFirms

    • Characs

  • kfFreq (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.

  • 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-weights

    • ew : equal-weights

  • printkfName (bool) – Flag for choosing whether to print or not print the specific name of Ken French’s data filename.

Returns

dfkf – Cleaned dataset queried from Ken French’s online library containing Fama-French-style factors, portfolio returns, number of firms in each portfolio, or average anomaly portfolio characteristics observed at frequency kfFreq over sample period from dt_start to dt_end for a given portfolio sorting strategy.

Return type

pandas.DataFrame