Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

# Introduction

In this post, I provide R code that enables the replication of the Center for Research in Security Prices (CRSP) Volatiliy Deciles using Yahoo! Finance data. This post is related to my last blog post in that it will generate the CRSP low volatility decile portfolio, thereby facilitating the replication of the associated EMA trading strategy.

There are a few caveats to this replication:

• There will be survivorship bias since Yahoo! Finance does not contain de-listed stocks
• This code takes a long time to run (+2 hrs on my machine, excluding downloading the symbols), and so it should not all be executed at once
• The parallel processing libraries in this code run in linux
• For Windows, “library(snow)”” should be used instead of “library(parallel)” and “library(doSNOW)” should be used instead of “library(doParallel)”
• A SOCK cluster will likely need to be used instead of a FORK cluster
• Consequently, objects, functions and libraries will have to explicitly be exported to the cores, thereby consuming more RAM
• There are +5,000 securities to download from Yahoo! Finance, and any one of them can fail randomly, thereby yielding different results each time the code is executed
• It is up to the individual user to decide if they want to download the failed symbols
• The quality control [QC] for this code is not exhaustive, i.e. my goal was to quickly get data for a time-sensitive paper-replication project, thus there is potential for more QC, which I will indicate in the post

This code is related to a paper replication project for a course I took over the summer of 2016 (Advanced Trading System Design). I will be sharing the project in a subsequent post.

To run the following script, one of my packages, titled tsconv (which stands for “Time Series Convenience”) needs to be installed. The following line of code will install the package, provided that the devtools library is already installed.

devtools::install_github("erolbicero/tsconv")