The tidyfinance package
tidyfinance is a package that contains a set of helper functions for empirical research in financial economics, addressing a variety of topics covered in this book. We designed the package to provide easy shortcuts for the applications that we discuss in the book. If you want to inspect the details of the package or propose new features, feel free to visit the package repository on GitHub.
The R package lives in the r-tidyfinance repository.
The Python package lives in the py-tidyfinance repository.
Installation
Usage
Throughout the book, we refer to the corresponding features of the tidyfinance package. At a high level, the package groups its functionality into a few families:
- Data access via a single
download_data()entry point, which dispatches on adomain(e.g.,"WRDS","Fama-French","Goyal-Welch","FRED","Stock Prices","Index Constituents","Tidy Finance") and adatasetargument. The package also ships adomain = "Pseudo Data"for generating pseudo data with the same schema as the WRDS datasets, which is handy for examples and testing without WRDS access. You can list everything that is available vialist_supported_datasets(). - Portfolio sorts through
assign_portfolio(),compute_breakpoints(),compute_portfolio_returns(),compute_long_short_returns(), and the convenience wrapperimplement_portfolio_sort(), configured via helpers such asbreakpoint_options(),data_options(), andfilter_options(). - Estimation with
estimate_model(),estimate_betas(), andestimate_fama_macbeth(), plus utilities likecreate_summary_statistics(),winsorize(),trim(), andadd_lagged_columns().
For the precise signatures and the latest changes, consult the package website.
For the precise signatures and the latest changes, consult the library website.
Feature requests
We are curious to learn in which direction we should extend the package, so please consider opening an issue in the package repository. For instance, we could support more data sources, add more parameters to the family of functions for data downloads, or we could put more emphasis on the generality of portfolio assignment or other modeling functions. Moreover, if you discover a bug, we are very grateful if you report the issue in our repository.