API Reference

This is a comprehensive reference for everything you get when you import famafrench.

wrdsConnection Constructor

wrdsConnection

Class for setting up the remote connection to wrds-cloud; largely builds on the Connection class in the WRDS-Py library.

Connecting to wrds-cloud

connect

Make a connection to the wrds-cloud database.

close

Close the connection to the database.

get_wrds_table

Create a pandas.DataFrame from an entire table in the database.

raw_sql

Query the wrds-cloud database using a raw SQL string.

wrds-cloud Query Tools

FamaFrench.queryComp

FamaFrench.queryCrsp

FamaFrench.queryCrspdlret

FamaFrench.queryrf1m

FamaFrench.getCrspDailyRollVar

FamaFrench.aggregateME

FamaFrench.getMEDec

FamaFrench.getMEJune

FamaFrench.mergeCCM

Constructing Portfolios and Return-Based Factors

FamaFrench.getNyseThresholdsAndRet

FamaFrench.getPortfolios

FamaFrench.getPortfolioReturns

FamaFrench.getNumFirms

FamaFrench.getCharacs

FamaFrench.getFFfactors

Comparing to Ken French’s Online Library

FamaFrench.kfLibrary

FamaFrench.getkfPortfolioReturns

FamaFrench.getkfNumFirms

FamaFrench.getkfCharacs

FamaFrench.getkfFFfactors

Summary Statistics and Diagnostics

FamaFrench.getFamaFrenchStats

FamaFrench.comparePortfolios

Auxiliary Functions and Utilities

lru_cached_method

Wrapper for methodtools.lru_cache() enabling recognition of decorated class instance methods by Sphinx.

get_kfpriorfactors_directly

Directly download (from Ken French’s online library) zipped monthly or annual datafiles for the Short-Term Reversal or Long-Term Reversal Fama-French-style factors.

timing

Wrapper for class instance methods enabling the timing of execution.

any_in

Boolean variable that is True if elements in a given set a_set intersect with elements in another set b_set.

priormonthToDay

Consistent w/ Fama and French (2008, 2016), map the prior (j-k) monthly return strategy into a daily strategy (see Ken French’s online documentation).

grouped_vwAvg

Calculate (net) weighted portfolio return for portfolio with weights col_weights within a group or groups.

portRetAvg

Compute a simple average across different columns.

get_statsTable

Construct detailed tables with summary statistics.