July 30, 2007

Using Genetic and Evolutionary Algorithms to Build a Trading Model

Ugly posted a great article from the New Scientist magazine that discusses how scientists are using Genetic and Evolutionary algorithms to solve all kinds of problems. The article highlights a few uses for these algorithms such as finding the optimal hull shape for boats or determining the best design for cochlear implants.

Still though, why should you even bother using Genetic and Evolutionary algorithms in the first place? The reason why is because these algorithms use an evolutionary approach to selecting the best fit” input variables. They’ll forward project outcomes to see which evolutionary path provides the best result for your output variable by transforming the input variables. In some cases they’ll even mutate the œoffspring” to see what happens to your output!

What makes these algorithms so vastly different then just using a standard back propagation or regression algorithm is that they work by œpreprocessing” your input data and help build a highly correlated model by transforming your data in the most robust input data set it can.

Now I’ve only scratched the surface of using Genetic and Evolutionary algorithms in YALE and there’s tons more for me to learn, but I’ve used them before in my experiments have had good success. Here are some examples where I’ve used them before:

  • I’ve used them to automatically select the best inputs from a list of 100 stock symbols and data points that help best explain my single output variable
  • I’ve used them to build weights” for my fundamental data trading model (still in Beta), and
  • I’ve even crossbred ETFs to make hybrid ETFs (that’s a bit weird but I was experimenting).

All of these algorithms are found in YALEs preprocessing data section and all of them are used right after you load your data into the experiment. They then apply their algorithms and preprocess” your data before the experiment learns” a model.

To show you how easy it is to use these types of algorithms in YALE/Rapidminer, I’m posting a small example of how to build a trading model using fundamental data. I won’t go into detail about all the different settings for the EA and we’ll just use the default settings for this experiment. First download the following files:

The Excel data file: Fundamental Data

The YALE XML file (in zip format): EA Experiment

EA Experiment.

Open YALE and load in your XML file and then the Excel Data file. Your experiment should look something like the image to the left.

This experiment takes fundamental data on several stocks such as book value, dividends payout, and EBITA, and tries to explain the output variable œ1 Year Target Price” (or some other measure of your choosing).

EA Weights.

If you have 100 years of time to spare you can assign weights to each of your input variables and then vary them till they match your output variable. The other faster way of doing this is to let YALEs Evolutionary Weighting algorithm preprocess the data for you.

Then, the newly assigned weights are fed into the learner, in this case a SVM learner, and the model learns the relationships between the data. Once the model has finished learning, you should be left with a highly correlated model! Voila, you have now built a machine learned model using Evolutionary algorithms!

As always, if you have any questions, please email me or leave me a comment! Thanks!

Genetic Algorithms tutorials RapidMiner

Previous post
Calculating Historical Volatility Hi there!   This is one my most popular posts and I would love it if you became an RSS Reader! The inspiration for my S&P500 Volatility
Next post
Draft Presentation Done - Germany Awaits I’m done with my draft presentation for RCOMM 2010 and hopefully will wrap it up over the weekend and then its to Germany in two weeks.  Its hard