On his Automated Trading blog, Max Dama takes us through the process of implementing a trading model using bagged decision trees in R. Not only does he provide the code and sample data (illustrating how to optimize trading of the financial instrument GLD via backtesting), he also walks us through the code step-by-step in a narrated video. It's a nice illustration of the practical steps of building bespoke models to financial data in R.
The code makes use of the Andy Liaw's
randomForest package to fit the bagged decision trees, a process that lends itself nicely to parallel computing. If you have a multiprocessor machine (or a cluster) and
REvolution R Enterprise, the
randomShrubbery function in
ParallelR acts as a drop-in replacement for
randomForest and runs in parallel, reducing the computation time for the backtesting.
Link to original post