Welcome!

SOA & WOA Authors: David Deans, Salvatore Genovese, Yeshim Deniz, Christopher Keene, Dave Haynes

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

The Components of the Genetic Application
There are three key components that must be defined in a classic genetic application: a pre-defined set of Genomes, some number of Expression Trees that will be determined at run time, and a Generator.

A Genome represents some small combination of decision points, which are known as Functions, and operations, which are known as Terminals. In our model, a typical Genome might say, “If the stock is overpriced, sell it.” In this case, the decision “is this stock overpriced?” is a Function, which is supported by a single terminal: sell it. If we added the instruction that it should buy any stock that is not overpriced – an “else” clause – then we would have two terminals within this Genome.

Expression Trees are collections of Genomes that represent the complete body of intelligence for a given stock selection agent in our algorithm. By combining multiple Genomes, we can arrive at Expression Trees that are complex enough to buy, short sell, or ignore stocks under a variety of circumstances.

The Generator is the part of our architecture that is responsible for creating a new Expression Tree for every agent in each new generation. The Generator must then assess the degree of success for each Expression Tree and ensure that more successful Expression Trees are used as a basis for agents in succeeding generations rather than less successful ones. In our case, the successfulness of an expression tree will be determined by the average ratio between the original price of a stock and the price of its last execution, inverted if the “short sell” operation was selected, compared to a fixed amount of inflationary-related loss when algorithms choose to ignore stocks.

Table 1 shows an example that might make this clearer. We’ve chose a 3% rate of inflation, which is extremely high for a daily rate, but the amount of gains might be similarly high, depending on the stock and volatility of the market.

We are using large numbers for illustrative purposes, to make the differences more apparent.

Choosing a Grid Architecture
Digipede supports six primary models of usage. Table 2 briefly summarizes each option and the degree to which it is a fit for our application.

As you can see in Table 2, we’re going to use the Executive Worker pattern to implement our distributed genetic algorithm for stock selection. Our main application will download the list of top stocks, create an initial set of Worker objects containing our first Expression Trees, then submit a JobTemplate to Digipede that contains this information and specifies an Executive component. When the job is submitted, all of this will be streamed out to the remote computing resources. These agents on these remote resources will load the Executives and keep them in process will the Expression Trees are run. Every N generations (configurable), the most successful Expression Tree from each Executive will be returned to the main Generator for cross-breeding and redistribution, along with a new stock list.

Next Steps
Now that we understand the basic principles and design for our solution, it’s time to delve into the code. Part Two of this article will walk through our implementation, discuss issues, and present a few opportunities for further improvement.

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.