[R-SIG-Finance] Compiling R code / java trading framework

Joshua Ulrich josh.m.ulrich at gmail.com
Sat Mar 17 17:31:14 CET 2012

On Fri, Mar 16, 2012 at 3:34 PM, Pierre-Alexandre <p.desmazis at gmail.com> wrote:
> Hi everyone,
> R is a very nice tool to elaborate complex trading strategies and pretty quickly.
> Nevertheless as the portfolio of strategies grows it becomes more and more time consuming to calculate the positions to execute.
This is true of any language.

> Also I found it difficult to create a robust trading framework based on R. For example in many language it is much more easy to handle large number of files and classes (UML modelling, MVC, convention over configuration, repository....).
> My question is in two parts.
> 1- How would you structure your code so it stays manageable when you have a very large number of function and tools. In this field R is ok for short code but when it comes to manage trading platform it is very quickly a mess. so you have any good example of trading frameworks in R (or R combined with other languages)
Create a package.  See quantstrat:

> 2- to increase speed I saw that it should be possible to compile the code written in R since R 2.13. Do you confirm? Would you recommend that and do you have any tutorial or example on how to do that ?
Yes, via the compiler package.  A tutorial isn't necessary.  Just read
the ?compile help file.

> In the end I was thinking about back testing in R and then recoding the strategies in another more structured and fast Langage like java for execution.
> But I think it is time consuming and it is a very bad idea  to recode your backtest in the end because it is going to create many discrepancies and errors.
> Let me know what you think
You could write the more time consuming parts in C/C++ using R's C API
and/or Rcpp.

Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

R/Finance 2012: Applied Finance with R

More information about the R-SIG-Finance mailing list