-
Notifications
You must be signed in to change notification settings - Fork 8
/
README.Rmd
81 lines (53 loc) · 3.54 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
# qmj (Quality Minus Junk)
Authors : Eugene Choe, David Kane, Ryan Kwon, Anthoney Tsou
To install the package:
```{r}
library(devtools)
install_github("anttsou/qmj")
```
##Background
qmj implements the results and methodology of the paper Quality Minus Junk by Clifford Asness, Andrea Frazzini, Lasse Pedersen. They use several measures to calculate scores for the relative profitability, growth, safety, and payouts of a company. Combining those scores generates an overall quality score.
High quality companies are likely outperform the market, while "junk" companies are likely to underperform.
Here we use the equations and methods described in the paper, coupled with data scraped from online sources, in order to produce quality measurements for companies listed in the Russell 3000 Index.
##Getting Started
In order to start you off, qmj comes equipped with several data sets, including company information, financial statements, and daily stock data. To access them, call:
```{r}
library(qmj)
companies <- qmjdata::companies ## Stores company names and tickers from the Russell 3000 index.
financials <- qmjdata::financials ## Stores financial documents for the given list of companies.
prices <- qmjdata::prices ## Stores price returns and closing stock prices for the past two years.
quality <- qmjdata::quality ## Stores the quality scores and the scores of its components.
```
Getting a quality data frame and a holistic summary of all its components can be done by calling
```{r}
market_data(companies, financials, prices)
```
If you're only interested in accessing certain quality factors, such as profitability, as well as what makes it up (such as gross profits over assets (GPOA), or cash flow over assets (CFOA)) call
```{r}
market_profitability(companies, financials)
```
This will return a data frame containing profitability z-scores for the given companies as well as the z-scores for the components creating the profitability scores.
##Updating your Data
Suppose you want to use the qmj package for your a custom set of companies, a dataset we will call "custom_companies". You can generate the most recent financial statements for those companies as follows:
```{r}
## Note that your custom data frame of company names and tickers must have the column name
## "ticker" for the column of tickers.
## Retrieves raw financial statements from google finance through the quantmod package.
rawdata <- get_info(custom_companies)
## Renders raw data in a format usable by other functions in this package
## and also dramatically improves readability.
financials <- tidyinfo(rawdata)
```
get_info also allows you to resume your downloading if the process is interrupted for any reason.
##Updating Prices
Updating prices is a separate, lengthy process, and for that reason is separated from the other functions that automatically collect financial statements. To update prices, which is necessary for calculating safety measurements, call:
```{r}
## Retrieves stock price data from Google Finance for listed companies for the past two years.
## Also saves data from the S&P 500, retrieved from Yahoo Finance.
rawprices <- get_prices(custom_companies)
## Renders the raw data into a form usable by other functions in this package.
prices <- tidy_prices(rawprices)
```
Similar to the get_info function, The get_prices function is also able to save its progress and resume previous downloads.
##More Information
More information, especially regarding methodology and what measures were used to filter out companies with bad or insufficient data, may be found in our vignette.