Skip to content

Installation guide for Windows

milktrader edited this page Apr 30, 2014 · 1 revision

The following assumes you have R installed. If not, please install R first.

You will need to install Rtools to build package from source as well. You can download latest version of Rtools from http://cran.r-project.org/bin/windows/Rtools/

You will also need svn installed. You can download simple SVN client from http://www.sliksvn.com/en/download

Once R, RTools, SVN are installed on your windows system, you will need to make sure that your Environment PATH variable has all the following directories included.

  • full path\Rtools\bin
  • full path\Rtools\gcc-4.6.3\bin
  • full path\R\bin
  • full path\SlikSvn\bin

See example below

PATH=c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Java\jre7\bin;C:\curl;E:\R\bin;C:\Program Files\SlikSvn\bin

Now time to install quanstrat.

Note that these packages have several dependencies (other packages including xts, quantmod) that you may or may not have already installed. The best way to install these packages is through the R console.

There are two methods to install 'blotter' family of packages

Using pre-built binaries from R-Forge.

You can install FinancialInstrument , blotter and quantstrat by specifying their repository, like this:

R> install.packages("FinancialInstrument",repos="http://r-forge.r-project.org")
R> install.packages("blotter",repos="http://r-forge.r-project.org")
R> install.packages("quantstrat",repos="http://r-forge.r-project.org")

This is unreliable though and doesn't work for every package, including RTAQ.

R> install.packages("RTAQ", repos="http://r-forge.r-project.org")
Warning message:
packageRTAQis not available (for R version 2.15.1) 

A more reliable way to install this bleeding-edge code is to get it onto your computer.

Using latest source code from SVN repository

Open a console prompt and navigate to directory where you would like to download the source code. Then execute following command (Note: in example below E:\R-Package is directory where source code will be downloaded)

E:\R-Package>svn checkout svn://svn.r-forge.r-project.org/svnroot/blotter/

From here, cd to what you just downloaded and see what you got.

E:\R-Package>cd blotter/pkg/
E:\R-Package\blotter\pkg>dir

 Directory of E:\R-Package\blotter\pkg

12/08/2012  01:12 AM    <DIR>          .
12/08/2012  01:12 AM    <DIR>          ..
12/08/2012  01:12 AM    <DIR>          blotter
12/08/2012  01:13 AM    <DIR>          FinancialInstrument
12/08/2012  01:11 AM    <DIR>          quantstrat
12/08/2012  01:12 AM    <DIR>          RTAQ

Now you can install FinancialInstrument package first using following command

E:\R-Package\blotter\pkg>R CMD INSTALL FinancialInstrument

You should see following messages on successful installation

* installing to library 'E:/R/library'
* installing *source* package 'FinancialInstrument' ...
** R
** data
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64

* DONE (FinancialInstrument)

Similarly you can install rest of packages with following commands

E:\R-Package\blotter\pkg>R CMD INSTALL blotter
E:\R-Package\blotter\pkg>R CMD INSTALL quantstrat

You should now have the code to begin implementing your trading strategy in R.

Congratulations!