Skip to main content

download_open_source.download_data_factors_ff()

Download and process Fama-French factor data.

Usage

Source

download_open_source.download_data_factors_ff(
    dataset=None, start_date=None, end_date=None, type=None
)

Downloads and processes Fama-French factor data based on the specified dataset name and date range. The data is downloaded directly from Kenneth French’s data library and processed into a structured format, including date conversion, scaling of factor values, and filtering by the specified date range.

If there are multiple tables in the raw Fama-French data (e.g., value-weighted and equal-weighted returns), the function only returns the first table because these are the most popular. Download the source ZIP archive directly if you need less commonly used tables.

Parameters

dataset: str = None

The name of the Fama-French dataset to download (e.g., ‘Fama/French 3 Factors’).

start_date: str = None

A character string or date in ‘YYYY-MM-DD’ format specifying the start date for the data. If not provided, the full dataset is returned.

end_date: str = None

A character string or date in ‘YYYY-MM-DD’ format specifying the end date for the data. If not provided, the full dataset is returned.

type: str = None
Deprecated. Use ‘dataset’ instead. If supplied, the value is translated to a dataset name via ‘list_supported_datasets’ and a DeprecationWarning is emitted.

Returns

pl.DataFrame
A data frame with processed factor data, including the date, risk-free rate, market excess return, and other factors, filtered by the specified date range.

References

Fama, E. F., and French, K. R. (1993). Common risk factors in the returns on stocks and bonds. Journal of Financial Economics, 33(1), 3-56. https://doi.org/10.1016/0304-405X(93)90023-5

Fama, E. F., and French, K. R. (2015). A five-factor asset pricing model. Journal of Financial Economics, 116(1), 1-22. https://doi.org/10.1016/j.jfineco.2014.10.010

Carhart, M. M. (1997). On persistence in mutual fund performance. Journal of Finance, 52(1), 57-82. https://doi.org/10.1111/j.1540-6261.1997.tb03808.x

Examples

from tidyfinance import download_data_factors_ff
download_data_factors_ff(
    'Fama/French 3 Factors', '2000-01-01', '2020-12-31'
)
download_data_factors_ff(
    '10 Industry Portfolios', '2000-01-01', '2020-12-31'
)