Welcome!

SOA & WOA Authors: Yeshim Deniz, Christopher Keene, Salvatore Genovese, Dave Haynes, Mark O'Neill

Related Topics: .NET, SOA & WOA

.NET: Article

Timing the Market with Distributed Genetics

Taking the winning side in trades using Genetic Programming and Grid Computing

Genetic Programming
Sometimes, you want to solve a problem and you’re pretty sure what a solution would look like, and what the pieces and players are that would have to be involved in any solution – but you’re just not quite sure how to manipulate those pieces in order to get to your envisioned solution. A game of chess is a good real-world example; I know that I need to manipulate my pieces according to a fixed set of rules until I can put my opponent’s king in a state of checkmate, but the exact series of steps I need to take in order to do that can be difficult to see.

Genetic programming uses a model for solving such problems that simulates biological evolution. A number of solutions are randomly generated, then tried and evaluated on the basis of how close they come to solving the problem at hand. Depending on how good or poor a given solution seems to be it will either become the starting point for additional, randomly generated solutions, or dropped from further consideration.

In evolutionary terms, this is similar to the way in which new mutations within a species prove to be beneficial, harmful, or neutral over time. A caveman with a third arm might have found that he was better-equipped for hunting. This might have made him especially popular with the cave ladies and, as a result, he had more offspring and a greater impact on succeeding generations. By way of contrast, a modern-day salesman with a third arm would probably not be as successful – constantly getting it caught in revolving doors and such – and as a result would probably die without progeny, living in the proverbial van down by the river.

The .NET Tool Kit
There is certainly much to be said for creating your own base frameworks for either grid or genetic algorithm applications. The degree of control possible when you roll your own implementations will always exceed anything that is available off-the-shelf. For most applications, however, a couple of base frameworks have developer editions that can be freely used in a limited capacity.

The Digipede Framework
Digipede is a .NET-based framework for grid computing. It provides three essential pieces right out-of-the-box. First, there is a Digipede Server, Digipede Workbench and Control. These applications work together to coordinate and allow you to monitor the independent units of work that you have out on your grid. You typically install these on a single computer in your network.

Second are the Digipede Agents. You will typically install a Digipede Agent on every machine that you want to have performing work as a part of your grid computing environment. The free Developer Edition allows you to install a maximum of two Agents – enough to allow you to completely build and test a grid program, but probably not enough to leverage much benefit for many grid-worthy computing applications.

Finally, and in many ways most important, is the Digipede Framework itself. By providing just a handful of classes for extension and/or consumption, Digipede allows you to focus on writing the “business logic” you need to have running on a grid. The Digipede software will completely handle the relatively inane tasks of distributing and coordinating the tasks you need to have performed across your grid.

John Koza’s Genetic Programming Textbook
The other bit of freely available framework that we will use as the starting point for our application is John Koza’s excellent textbook on the topic of genetic programming called, simply, Genetic Programming: On the Programming of Computers by Means of Natural Selection. In this textbook, Mr. Koza lays out a framework for genetic programming that we will follow very closely in our construction of a stock-picking grid application.

Designing the Stock Selection Application
In order to build an application that is capable of selecting stocks, evaluating the appropriateness of those selections over time, and then adjusting itself for greater accuracy in the future, we will need to provide our application with some data on which to base its selections. This leads us to the first question that typically presents itself in developing genetic algorithms: On what kind of data should its decisions most likely be based?

A quick review of financial planning guides, trading websites, etc., will quickly cause you to zero in on a handful of likely data points for long-term financial analysis. For this engine, we will use the “Real Time Market Data” web service made available by WebServiceX.NET.

This web service provides a façade over the market data published by the INET electronic exchange. The operations we are interested in, specifically, are:

  • TopLists: We will use this to retrieve a base list of 500 stocks that our application will evaluate and decide whether to buy, sell, or hold (ignore).
  • LastExecution: We will evaluate the effectiveness of our algorithms by comparing the price on the last execution for a stock to the last price initially given by the TopLists operation for that stock.

More Stories By Derek Ferguson

Derek Ferguson, founding editor and editor-in-chief of .Net Developer's Journal, is a noted technology expert and former Microsoft MVP.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.