The tidyfinance Package
The companion tidyfinance package bundles the small, repetitive tasks that show up in almost every project — chiefly one-line downloads of common datasets behind a single download_data call. This keeps the later chapters focused on ideas rather than plumbing. Use the R | Python toggle to switch.
Installing and exploring
After installing, list_supported_types shows everything the package can fetch by name — Fama–French factors, q-factors, macro predictors, WRDS tables, and more.
install.packages("tidyfinance")
library(tidyfinance)
list_supported_types()
# pip install tidyfinance
import tidyfinance as tf
tf.list_supported_types()
One-line downloads
Each dataset is one call: name the type and (optionally) a date range, and you get back a tidy table ready to join. No remembering URLs or file formats.
download_data(type = "factors_ff_3_monthly")
tf.download_data(domain="factors_ff_3_monthly")
download_data(
type = "factors_ff_3_monthly",
start_date = "2000-01-01",
end_date = "2020-12-31"
)
tf.download_data(
domain="factors_ff_3_monthly",
start_date="2000-01-01",
end_date="2020-12-31"
)
Why wrap it
Hiding boilerplate behind named functions has two payoffs: scripts read like the analysis you intend, and a fix to a download quirk lives in one place rather than scattered across files. The same download_data interface reappears in every data chapter, which is what keeps them concise.
Study notes following the Tidy Finance curriculum by Scheuch, Voigt, Weiss, and Frey. Prose is my own; the R/Python code is reproduced from the book's open-source source, licensed CC BY-NC-SA 4.0.