|
1 | 1 | # Open source cross sectional asset pricing |
2 | 2 |
|
3 | 3 | This repo accompanies our paper: |
4 | | -[Chen and Zimmermann (2020), "Open source cross-sectional asset pricing"](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3604626) |
| 4 | +[Chen and Zimmermann (2021), "Open source cross-sectional asset pricing"](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3604626) |
5 | 5 |
|
6 | | -If you use data or code based on our work, please cite the paper: [Bibtex entry](https://drive.google.com/open?id=1eP-Tuvmcbs5A7073d_9g2wQbvitqfdPz) |
| 6 | +If you use data or code based on our work, please cite the paper: |
| 7 | + |
| 8 | +~~~ |
| 9 | +@unpublished{ChenZimmermann2021, |
| 10 | +author = "Chen, Andrew Y. and Tom Zimmermann", |
| 11 | +title = "Open Source Cross Sectional Asset Pricing", |
| 12 | +note = "available at https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3604626", |
| 13 | +year = 2021 |
| 14 | +} |
| 15 | +~~~ |
| 16 | + |
| 17 | + |
| 18 | +---- |
7 | 19 |
|
8 | 20 | ## Data |
9 | 21 |
|
10 | 22 | If you are mostly interested in working with the data, we provide benchmark signal and portfolio returns in separate files for direct download. |
11 | 23 |
|
12 | | -You can access the benchmark data [here](https://drive.google.com/open?id=1oeX3PVd5KxKqnQuVuPdRwORrqyt1WnJo). |
| 24 | +You can access the benchmark data [here](https://sites.google.com/site/chenandrewy/open-source-ap). Please see the [data documentation](https://drive.google.com/file/d/1adFWMGcXEzF2Jls3qTtqb1fmXUTsRBr1/view?usp=sharing) for a description of individual files that are available. |
13 | 25 |
|
14 | | -The folder contains 4 files |
| 26 | +For reference to individual signals, their acronyms and construction please see the [online appendix to our paper](https://drive.google.com/open?id=1vXRzjxYucXZV-tgLxM26fvRZ5zKvlBXH) and the file `SignalDocumentation.xls` that is part of this repo. |
15 | 27 |
|
16 | | -- Portfolio Returns Benchmark Signals: portbase.zip |
17 | | -- Portfolio Returns Additional Signals: portadditional.zip |
18 | | -- Firm-level benchmark signals: signalbase.zip |
19 | | -- Firm-level additional signals: signaladditional.zip |
| 28 | +---- |
20 | 29 |
|
21 | | -For reference to individual signals, their acronyms and construction please see the [online appendix to our paper](https://drive.google.com/open?id=1vXRzjxYucXZV-tgLxM26fvRZ5zKvlBXH) and the file **SignalDocumentation.xls** that is part of this repo. |
| 30 | +## Code |
22 | 31 |
|
| 32 | +The code is separated into two parts: |
23 | 33 |
|
24 | | -## Code |
| 34 | +1. **Signals**: Contains code to produce stock-level signals |
| 35 | +2. **Portfolios** Contains code to produce portfolio returns |
| 36 | + |
| 37 | +You can download the individual signals that are outputs of the **Signals** part of the code from the data repository above and start from the **Portfolios** part if you like. |
| 38 | + |
| 39 | +### 1. Signals |
| 40 | + |
| 41 | +The **Signals code** provides scripts for `DataDownloads`, `Predictors` and `Placebos`. The `master.do` file runs all files but you will need to set paths pointing to your project folder, your R installation and your WRDS connection (see below). |
| 42 | + |
| 43 | +*Optional (i.e. code is modular and will work even if you do not do that)*: To construct signals that rely on IBES, 13F, TAQ or OptionMetrics data run the SAS scripts in `PrepScripts` on the WRDS server. See the [WRDS instructions](https://wrds-www.wharton.upenn.edu/pages/support/programming-wrds/programming-sas/) for different ways to run these scripts on the WRDS server. Copy the output of those scripts to `Signals/Data/Prep`. Code to construct trading costs from TAQ data is provided separately and can be downloaded [here](https://drive.google.com/open?id=1W256-g-RxqOZBjNtkSJuuWXUqHZEYHsM). |
25 | 44 |
|
26 | | -The code is separated into different files that download and prepare the data, and construct signals and portfolios. Please see the file **runEverything.txt** to get an overview of how the entire code can be run. The current code does some parts in R and some in Stata, so you will need both to run everything. |
| 45 | +*See **Data access** part of the readme below for some data access steps that you need to complete before you can run the code.* |
27 | 46 |
|
28 | | -Code to construct trading costs from TAQ data is provided separately and can be downloaded [here](https://drive.google.com/open?id=1W256-g-RxqOZBjNtkSJuuWXUqHZEYHsM). |
29 | 47 |
|
| 48 | +### 2. Portfolios |
| 49 | + |
| 50 | +The _Portfolios_ code constructs portfolio returns from the signal files. The `master.R` can serve as a reference as to the order in which files should run. You need to set the project folder (same as for the Stata code) in `00_SettingsAndTools.R` for everything to work. |
| 51 | + |
| 52 | +---- |
30 | 53 | ## Data access |
31 | 54 |
|
| 55 | +### 1. Wharton Research Data Services |
| 56 | + |
32 | 57 | To download raw data from the original sources, you will need access to WRDS. At a minimum, you will need access to the following databases: |
33 | 58 |
|
34 | 59 | - CRSP |
35 | 60 | - Compustat |
36 | 61 | - IBES |
37 | 62 |
|
38 | | -WRDS provides [instructions for setting up WRDS to work via RStudio on your computer](https://wrds-www.wharton.upenn.edu/pages/support/programming-wrds/programming-r/r-from-your-computer/) |
| 63 | +To run the download scripts, you will need to install an ODBC driver and have a working Stata version. [WRDS provides instructions for setting up WRDS to work via Stata on your computer.](https://wrds-www.wharton.upenn.edu/pages/support/programming-wrds/programming-stata/stata-from-your-computer/) |
| 64 | + |
| 65 | +A few R scripts download CRSP data directly. WRDS provides [instructions for setting up WRDS to work via RStudio on your computer](https://wrds-www.wharton.upenn.edu/pages/support/programming-wrds/programming-r/r-from-your-computer/) |
| 66 | + |
| 67 | + |
| 68 | +### 2. FRED |
| 69 | + |
| 70 | +To download macroeconomic data required for some signals, you will need to [request an API key from FRED](https://research.stlouisfed.org/docs/api/api_key.html). Before you run the download scripts, you need to save your API key in Stata (either via the context menu or via `set fredkey`). |
| 71 | + |
| 72 | +---- |
39 | 73 |
|
40 | 74 | ## Contribute |
41 | 75 |
|
|
0 commit comments