Genetic optimization for Trading Strategies using Rapidminer and R

December 5, 2010
By

(This article was first published on a Physicist in Wall Street, and kindly contributed to R-bloggers)

That is the second tutorial of Rapidminer and R extension for Trading and the first in Video. In the last example the ROC obtained is not as good as it should be to make money in this business, To improve the strategy we will try to optimize the trading strategy. Different methods of optimization and objective functions for trading can be studied in the literature, Finally we will use a genetic non-multiobjetive to optimize our simple strategy.

The simple strategy defined is the following:
  • The symbol used is “IBM” (you can use any other symbol)
  • A SVM (Support Vector Machine) predicts the close value of the next day, and when the value is mayor than the previous day, we obtain a buy signal and otherwise a shell signal.
  • The training data used are historical prizes (close, high, volumen) from 2006 to 2009
  • The validation is done with historical information from 2010
  • It is calculated the following indicators RSI, EMA 7, EMA 50, EMA 200, MACD y ADX.
  • It is created a two days delay temporal window for all historical values.
For the optimization of the strategy it is used a genetic algorithm. The genetic algorithm will modify the input data by removing any entries (for example indicators) in order to maximize the ROC of the strategy . You can watch in the video the model generated:



The results are: Initial ROC of the past tutorial

  clip_image002


 The trading % win in the past strategy:

  clip_image004

 Evolving feature selection in 40 generation, the final ROC performance is improved.  

clip_image006
The ROC funtion improved is the following:
  clip_image008

 The % win trades is also improved

  clip_image010

It is possible to select other kind of optimization algorithm and to maximize or minimize other value like drawdown or other type of ratios like Kelly or sharpen ratio. In the next tutorial, I will improve the trading operation in order to make as real as possible and to incorporate as XML configuration files the symbols.

PayPal - The safer, easier way to pay online!DOWNLOAD FILES  2$ < clip_image014TO IMPROVE THE BLOG



To leave a comment for the author, please follow the link and comment on his blog: a Physicist in Wall Street.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.