In recent posts we have explored the performance assessment of a simple strategy. To improve this kind of evaluation and to enhance the capabilities of the use of R and RapidMiner for trading we have included the blotter library possibilities into the model evaluation (that not was simple due to the limitations of R extension). Blotter is an R package that tracks the P&L of your trading systems (or simulations), even if your portfolio spans many security types and/or currencies. This post uses blotter to track the blackbox trading strategy and it will allows us to manage different profiles with Rapidminer.
The basic strategy was done for GSPC and it is described in the following diagram
The trading strategy is divided into the generation of models, prediction and filtering spurious signals. The first step is the model generation, I tested different regression models, neural networks, SVM, etc for the prediction model generation. For spurious signals littering we have used a binary classification (bad prediction or correct prediction). The binary classification (correct or false prediction) is done using different rule extraction algorithms using as input only technical indicators.
The second step is the Evaluation of the strategy using the models generated in the previous step
To implement this strategy we have used Rapidminer and R plugin, you can see the complexity of the algorithm in the following picture. The main requirement is Blotter, however it is not yet in the cran repository, so you need to install from R-forge
you can see more information in:https://r-forge.r-project.org/R/?group_id=316
To use the last version of blotter you need to update R to the last one in that moment 2.12 version.
I will describe the most important R models, and in a future post I will describe, inside one video, all elements of the architecture.
The main elements are:
- Obtain Technical Data for Training model
- Evaluation Strategy
Obtain Technical Data for Training module
This module define, using blotter, the strategy described before.
It was defined three time interval, one for training (800 days), one for evaluation genetic space search (300 days) and finally the rest of the days for testing ( >200 days)
Several tests have been done using Neural Networks and SVM, obtaining diverse results, however always positive results. You can see in the following image the results obtained
Using neural network we have improved the performance of the strategy in the training and evaluation data, during 7 hours, 100 generations we obtain the following improvement (figure). We use the same technique than in previous post. It is not possible to use for evaluation Blotter due to the time consumption of this package.
The results obtained using this strategy, without filter can be observed in the following graph, the comparison was done with buy&hold strategy. Although backtesting is no guarantee of future performance, it gives the trader confidence that the strategy has worked in the past. If the strategy is not over-optimized, data-mined, or based on random coincidences, it might have a good chance of working in the future.
The Sharpe Ratio (Rf=0%) of this strategy is 2.46.
On the other hand if we use the filter
Using the filter, we reduce the drawdown peak; however we obtained lower return and a Sharpe Ratio of 2.18. Currently I’m doing several test with different filters however the Sharpe Ratio of the prediction algorithm without filter is very high for this index.
Also, you can modify the type of filter, for example you can see the filter obtained using J48 algorithm. The idea is to auto-generate and understand filters using technical indicators.
J48 pruned tree
RSI2-0 <= 44.156798: false (409.0/168.0)
RSI2-0 > 44.156798
| DX-0 <= 5.179328
| | DX-0 <= 2.667342
| | | tr-1 <= 4.81: false (10.33/2.33)
| | | tr-1 > 4.81: true (20.67/3.0)
| | DX-0 > 2.667342: true (24.0/1.0)
| DX-0 > 5.179328: true (536.0/255.0)
Number of Leaves : 5
Size of the tree : 9
The current problems of the model are:
- The accuracy of the long and short position prediction, it is not good should be improved.
- My objective is to reduce the risk of the strategy, so the the filter should be improved in order to reduce false signals.
- Reduce the number of variable to adjust for the strategy…
In the following post, I will describe in a video the model with all elements of the architecture, and I will try to discuss about the problems discovered in the strategy.
We do not guarantee that those strategies will give you profits or have mistakes. It is important to remember that each trading situation is unique. You can never copy a strategy and think that it will always work. It is allot factors to take consideration too. For example, how the game looks like, how the odds are moving etc. This blog is a research activity to share knowledge related to datamining and trading algorithms. All code described in this blog is GPL v3, We try to put all information about the model and how to generate the results obtained and also if you have any doubt about the model you will receive the answer by email or comments in the blog. If you don¡t have patient and you want to obtain the files you can, paying one small donation to improve the website,