程序代写案例-F540
时间:2021-04-02
F540 Data Download
Relevant data sources for F540 and how to use them
Christian Tien
6 March 2021
This document contains instructions how to choose your personalised random set of assets for the project
and information about how to access various sources of data, which are useful for this course.
Project Assets
For your project, you will choose a random set of 100 assets based on the numeric part of your candidate
number. A pool of assets with long-term monthly price data availability (30 years) has been supplied to you
in form of the file all_permnos.txt. The file is available on the Moodle page Data Download subsection.
1. Load the packages.
library(readr)
library(tidyverse)
2. Import the list of all PERMNOs (permanent numbers of assets). You may need to adjust the file path.
permnos <- read_csv("all_permnos.txt",
col_names = FALSE) %>% pull()
3. Set the seed to ensure you get the same assets every time this is run. Use the first four digits of your
exam candidate number, which takes the form 1234X. You have to leave the letter out, as below (for
1234X).
set.seed(1234)
4. Choose a random sample of 100 PERMNOs (without replacement)
mypermnos = permnos %>% base::sample(100)
5. Save your set of assets (identified by PERMNOs) as a text file. You can upload this to CRSP to
bulk-download data for each of the assets in the text file.
write.table(mypermnos,’mypermnos.txt’,
row.names=FALSE,col.names=FALSE)
1
Downloading Monthly/Daily Stock and ETF Data in CRSP
You can download prices, volume, shares outstanding and other basic information for assets in CRSP.
First you need a list of PERMNOs of interest. You could have a list of your personal 100 assets created as
explained above.
Alternatively, you could have a list of PERMNOs of ETFs. For example, this could be a subsample of the
124 ETFs with long-term monthly price data availability (16 years), which has been supplied to you in the
Data Download subsection on Moodle. ETFs in CRSP are identified by the Share Code 73, so if you want
to find other ETFs, feel free to look for them yourself by finding PERMNOs associated with Share Code 73.
1. Go to WRDS and sign in.
2. Go to CRSP > Stock / Security Files.
3. Choose monthly or daily stock files as appropriate.
4. In STEP 1 choose date range as appropriate.
5. In STEP 2 change selection from TICKER to PERMNO. (NB PERMNOs are better as they are
invariant over time - tickers can change.)
6. In STEP 2, check the button next to “Browse” and browse to upload your file of PERMNOs.
7. In STEP 3, select relevant query variables - e.g. price, volume, shares outstanding, holding period
return, . . .
8. Don’t worry about the conditional statement builder.
9. In STEP 4, set your desired output format (e.g. txt or csv).
10. Submit query.
11. Once your text (or csv) file is created, click the link and the right click “Save As” to save it.
Downloading Asset Fundamentals/Characteristics in CRSP
First you need a list of PERMNOs of interest.
1. Go to WRDS and sign in.
2. Go to WRDS > Financial Ratios Suite by WRDS > Financial Ratios Firm Level.
3. Change the date range (e.g. same as for your returns).
4. Change the company code to “PERMNO”.
5. Click the button next to “browse” and upload your file of PERMNOs.
6. In “Select your variables”, choose fundamentals or click “All” in the grey box next to the word “Select”.
• 99.4% of assets in all_permnos.txt have continuous monthly data for 31 informative fundamen-
tals since 2010. These fundamentals are all the fundamentals from rank 7-8 and 10-38 in the
few_na_fundamentals_description.csv file.
• 96.5% have continous monthly data for those same 31 fundamentals since 2005, 93.4% since 2000, and
84.2% since 1990.
• For larger sets of fundamentals your sample size decreases either in terms of time periods or assets.
7. Set your desired output format (e.g. txt or csv).
8. Submit query.
9. Once your text (or csv) file is created, click the link and the right click “Save As” to save it.
2
Downloading Fama-French Factors
Fama-French factors can be downloaded in Kenneth French’s data library on his website.
Downloading Other Factors
For example, AQR has factor data for 24 countries at daily and monthly horizons.
• Standard factors + QMJ
– See: “Quality Minus Junk”, Assness, C.S., A. Frazzini and L. H. Pedersen, Rev. Account. Stud.,
2018.
• Standard factors + BAB
– See: “Betting Against Beta”, A. Frazzini and L. H. Pedersen, Rev. Account. Stud., 2014.
You may find other factors, which you would like to include.
Downloading VIX in WRDS
The Chicago Board Options Exchange’s CBOE Volatility Index (VIX) is available in WRDS since 1990.
1. Go to WRDS and sign in.
2. Go to WRDS > CBOE Indexes.
3. STEP 1: Choose the date range (e.g. same as for your returns).
4. STEP 2: Choose which Index (VIX) and which type of price to download (OHLC).
5. STEP 3: Set your desired output format (e.g. txt or csv).
6. Submit query.
7. Once your text (or csv) file is created, click the link and the right click “Save As” to save it.
FRED Database
The Federal Reserve Economic Database (FRED) stores 788,000 economic time series from 103 sources. It
is a useful data source, e.g. for macroeconomic data.
3

























































































学霸联盟


essay、essay代写