finds.readers.ffreader
Wraps around pandas_datareader to retrieve French data library
MIT License
Copyright 2022-2023 Terence Lim
- class finds.readers.ffreader.FFReader(symbol)[source]
Bases:
object
Wraps over pandas_datareader to load FamaFrench factors from website
Hints for using pandas datareader to read a single series
from pandas_datareader.famafrench import FamaFrenchReader as FFR mkt = FFReader('F-F_Research_Data_Factors', start=1900, end=2099).read()
- static fetch(name: str, item: int = 0, suffix: str = '', date_formatter: ~typing.Callable = <function FFReader.<lambda>>) DataFrame [source]
Retrieve item and return as DataFrame
- Parameters:
name – Name of research factor in Ken French website
item – Index of item to research (e.g. 0 is usually value-weighted)
suffix – Suffix to append to name (e.g. to distinguish monthly from daily)
date_formatter – to reformat dates, e.g. bd.offset or bd.endmo
- Returns:
DataFrame of asset returns (converted to decimal, not percentages)
- static sectoring(scheme: str, source: str = '') DataFrame | None [source]
Load FamaFrench sectoring based on sic-4, from website or zipfile
- Parameters:
scheme – in {codes5, codes10, 12, 17, 30, 38, 48, 49}
Notes:
Retrieved from “https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/” + “ftp/Siccodes5.zip”
For example, the industry definitions file for Siccodes49 looks like:
1 Agric Agriculture 0100-0199 Agricultural production - crops 0200-0299 Agricultural production - livestock 0700-0799 Agricultural services 0910-0919 Commercial fishing 2048-2048 Prepared feeds for animals 2 Food Food Products 2000-2009 Food and kindred products 2010-2019 Meat products 2020-2029 Dairy products
- daily = [('F-F_Research_Data_5_Factors_2x3_daily', 0, ''), ('F-F_Research_Data_Factors_daily', 0, ''), ('F-F_Momentum_Factor_daily', 0, ''), ('F-F_LT_Reversal_Factor_daily', 0, ''), ('F-F_ST_Reversal_Factor_daily', 0, ''), ('49_Industry_Portfolios_daily', 0, '49vw'), ('48_Industry_Portfolios_daily', 0, '48vw'), ('49_Industry_Portfolios_daily', 1, '49ew'), ('48_Industry_Portfolios_daily', 1, '48ew')]
Common daily FF series, with subset index and a suggested suffix
- monthly = [('F-F_Research_Data_5_Factors_2x3', 0, '(mo)'), ('F-F_Research_Data_Factors', 0, '(mo)'), ('F-F_Momentum_Factor', 0, '(mo)'), ('F-F_LT_Reversal_Factor', 0, '(mo)'), ('F-F_ST_Reversal_Factor', 0, '(mo)')]
Common monthly FF series, with subset index and a suggested suffix