Over the years I have tried to simplify and streamline my access to financial historic data. All different solutions I tried (see here, for example) so far have been unsatisfactory, at least to some degree. That however changed after I started using R6. Here is an example of using the R6 class for the same task as before:
Category Archives: R
In an earlier post, I used mclapply to kick off parallel R processes and to demonstrate inter-process synchronization via the flock package. Although I have been using this approach to parallelism for a few years now, I admit, it has certain important disadvantages. It works only on a single machine, and also, it doesn’t work on Windows.
Have you tried synchronizing R processes? I did and it wasn’t straightforward. In fact, I ended up creating a new package – flock.
One of the improvements I did not too long ago to my R back-testing infrastructure was to start using a database to store the results. This way I can compute all interesting models (see the “ARMA Models for Trading” series for an example) once and store the relevant information (mean forecast, variance forecast, AIC, etc) into the database. Then, I can test whatever I want without further heavy lifting.
Over the years, there have been a couple of issues I have been trying to address in my daily use of this excellent package. Both are “cosmetic” improvements, they only improve the usability of the package. Let me share them and see whether they can be improved further.:)
Various of my R scripts produce csv files as output. For instance, I run a lengthy SVM back test, the end result is a csv file containing the indicator with some additional information. The problem is that over time one loses track what exactly the file contained and what parameters were used to produce it.
As mentioned earlier, currently I am playing with trading strategies based on Support Vector Machines. At a high level, the approach is quite similar to what I have implemented for my ARMA+GARCH strategy. Briefly, the simulation goes as follows: we step through the series one period (day, week, etc) at a time. For each period, we use history of pre-defined length to determine the best model parameters. Then, using these parameters, we forecast the next period.
Lately I have been working on a trading system based on Support Vector Machine (SVM) regression (and yes, if you wonder, there are a few posts planned to share the results). In this post however I want to share an interesting problem I had to deal with.
Few days ago, I started running simulations using my latest code over years of historic data. Everything seemed to work fine, and the results looked promising. Experience has thought me that there is nothing like too much testing when it comes to trading strategy simulations, in other words, when your money is on the line. So, I decided to run one more test, which I usually do – to confirm that simulations with the same parameters, produce the same indicator.