-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
117 lines (87 loc) · 3.41 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# tidyfinance
<!-- badges: start -->
`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")`
[](https://github.com/tidy-finance/r-tidyfinance/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
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()
```