A Julia package for easy access to the Ken French Data Library. The Ken French Data Library is one of the most highly used publicly available data sources for financial investments and asset pricing research.
Working with the data is sometimes tedious because the downloadable files come (1) compressed in zip archives and (2) having non-standard csv layouts. This package handles both of those hurdles, allowing users to get to the data faster.
To add the package, type ] add FamaFrenchData at the Julia REPL.
Once added, type using FamaFrenchData to import the package.
The package exports 4 functions: readFamaFrench, downloadFamaFrench, listFamaFrench, and clearFamaFrenchCache.
For help with any of these functions, use ? at the REPL (eg. ?readFamaFrench).
Please consult the online documentation for additional detail.
The package now includes automatic caching functionality to improve performance and reduce network requests. Downloaded data is cached locally and automatically expires after 24 hours (since the data is updated at most daily). This means:
- First call: Downloads data from the web and caches it locally
- Subsequent calls: Uses cached data if it's less than 24 hours old
- After 24 hours: Automatically downloads fresh data and updates the cache
You can customize this behavior:
# Use cache with default 24-hour expiration
tables, tablenotes, filenotes = readFamaFrench("F-F_Research_Data_Factors")
# Bypass cache for a specific call
tables, tablenotes, filenotes = readFamaFrench("F-F_Research_Data_Factors", use_cache=false)
# Use cache with custom expiration (12 hours)
tables, tablenotes, filenotes = readFamaFrench("F-F_Research_Data_Factors", cache_max_age=12)
# Clear all cached data
clearFamaFrenchCache()The Fama-French 3 factor model is a commonly used empirical asset pricing model. This example retrieves the full time series of FF3 monthly and annual returns.
using FamaFrenchData, DataFrames
# read the Fama-French 3 factors (monthly and annual)
tables, tablenotes, filenotes = readFamaFrench("F-F_Research_Data_Factors")
FF3_monthly = tables[1]
FF3_annual = tables[2]
# read the Fama-French 3 factors (daily)
tablesd, tablenotesd, filenotesd = readFamaFrench("F-F_Research_Data_Factors_Daily")
FF3_daily = tables[1]
# read the 25 Size-B/M portfolios (monthly and annual)
tables25, tablenotes25, filenotes25 = readFamaFrench("25_Portfolios_5x5")
FF_ME_BM_25 = tables25[1]I am not affiliated with the Ken French Data Library. This package does not "ship with" the data, just provides easier access to it. Other than the changes that I have explicitly stated, I do not alter the data; however, it is your responsibility to verify that the data is correct.