Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tidy-finance/r-tidyfinance
R package with helper functions for developers and researchers familiar with Tidy Finance
https://github.com/tidy-finance/r-tidyfinance
Last synced: about 2 months ago
JSON representation
R package with helper functions for developers and researchers familiar with Tidy Finance
- Host: GitHub
- URL: https://github.com/tidy-finance/r-tidyfinance
- Owner: tidy-finance
- License: other
- Created: 2024-02-08T17:24:44.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-13T19:19:47.000Z (3 months ago)
- Last Synced: 2024-09-14T10:19:04.254Z (3 months ago)
- Language: R
- Homepage:
- Size: 1.08 MB
- Stars: 11
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- trackawesomelist - tidyfinance (⭐12) - Tidy Finance helper functions to download financial data and process the raw data into a structured Format (tidy data), including (Recently Updated / [Oct 14, 2024](/content/2024/10/14/README.md))
- awesome-quant - tidyfinance - Tidy Finance helper functions to download financial data and process the raw data into a structured Format (tidy data), including (R / Data Sources)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# tidyfinance
`r badger::badge_cran_release()`
`r badger::badge_cran_download(type = "grand-total")`
`r badger::badge_repostatus("Active")`
`r badger::badge_github_version(color = "blue")`
[![R-CMD-check](https://github.com/tidy-finance/r-tidyfinance/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidy-finance/r-tidyfinance/actions/workflows/R-CMD-check.yaml)This repository contains an R package that collects helper functions for developers and researchers familiar with [Tidy Finance with R](https://www.tidy-finance.org/r/index.html). The functions provide shortcuts to selected issues that the book discusses in detail.
## Installation
You can install the released version of `tidyfinance` [from CRAN](https://cran.r-project.org/package=tidyfinance) via:
```r
install.packages("tidyfinance")
```You can install the development version of `tidyfinance` from [GitHub](https://github.com/tidy-finance/r-tidyfinance) via:
```r
# install.packages("pak")
pak::pak("tidy-finance/r-tidyfinance")
```## Usage
### Download Data
The main functionality of the `tidyfinance` package centers around data download. You can download most of the data that we used in [Tidy Finance with R](https://www.tidy-finance.org/r/index.html) using the `download_data()` function or its children. For instance, both functions give the same result:
```r
download_data(
type = "factors_ff_3_monthly",
start_date = "2000-01-01",
end_date = "2020-12-31"
)download_data_factors_ff(
type = "factors_ff_3_monthly",
start_date = "2000-01-01",
end_date = "2020-12-31"
)
```You can also download data directly from [WRDS](https://www.tidy-finance.org/r/wrds-crsp-and-compustat.html) (if you have set your credentials via `Sys.setenv(WRDS_USER = "your_username", WRDS_PASSWORD = "your_password")`), e.g.,
```r
download_data(
type = "wrds_compustat_annual",
start_date = "2000-01-01",
end_date = "2020-12-31"
)
```If you want to fetch additional columns that are not included in our default selection, then pass them as additional arguments in the corresponding child function:
```r
download_data_wrds_compustat(
type = "wrds_compustat_annual",
start_date = "2000-01-01",
end_date = "2020-12-31",
additional_columns = c("acoxar", "amc", "aldo")
)
```You can get a list of all currently supported types via `list_supported_types()`. Please open an [issue on GitHub](https://github.com/tidy-finance/r-tidyfinance/issues) to request additional supported types.
### Other Helpers
We include functions to check out content from [tidy-finance.org](https://www.tidy-finance.org/r/index.html):
```r
list_tidy_finance_chapters()
open_tidy_finance_website()
```There are also some simple helpers for regression analyses:
```r
winsorize()
trim()
create_summary_statistics()
```We also include (experimental) functions that can be used for different applications, but note that they might heavily change in future package versions as we try to make them more general:
```r
# For portfolio sorts
?assign_portfolio()# For model estimation
?estimate_model()# For beta estimation
?estimate_betas()# For beta estimation
?estimate_fama_macbeth()
```