The last few years have seen the broadening use of computational modelling in financial markets. Being
information driven trading environments, the inherent mathematical nature of financial markets (Chen,
Jain, & Tai, 2006) lend itself well to computerized modelling algorithms to make quantitative analyses
and explain informational patterns that would predict the dynamics of markets.
Stock market is a subset of financial markets where agents participate by trading company shares (stocks)
to generate monetary returns. The informational patterns of the stock market lie in the price movements of
the traded assets (Becker & O'Reilly, 2009) and thus, the participants (traders) of the market have
historically been analyzing the market trends and construct profitable investment strategies to exploit the
future direction of prices. (Holden, Peel, & Thompson, 1990) In this context, machine learning and
computational intelligence are effective tools in exploring non-linear and complex relationships that may
exist in stock markets which is not easily apparent to humans.
The learning technique that is of interest to this project is genetic programming. Researched under the
subject of evolutionary computation, genetic programming is a biologically inspired modelling algorithm
that evolves populations of computer programs by repeatedly assessing them over generations. (Poli,
Langdon, & McPhee, 2008) These programs provide an agent-based simulation of real world phenomena
by imitating the behaviours of agents in solving a defined problem setting. By passing the better
performing (strong) solutions to next generations and eliminating the weaker ones, genetic programming
applies a "survival of the fittest" methodology on optimizing solutions for uncertain and dynamic
There has been much work involving the application of genetic programming on the stock market context.
Attempts have been made to predict future price movements of stocks and develop optimal investment
strategies by imitating the operational patterns of traders on artificially simulated trading environments.
With its exhaustive searching capability, parallelism and the quickness of generating optimal solutions,
(Seshadri, 2003) the primary objective of genetic programming in this context is to create a computational
intelligence mechanism that can learn about the historical price movements of stocks and generate
strategies that can exploit the trends spotted in the data over future periods. This is in essence, a computer
science take on the technical trading concept, in which traders try to detect price patterns and buy assets
when they are low priced and sell when they are high.
So far, the previous studies done on this area were mostly investigative. Different genetic programming
structures were proposed to model stock market behaviour and a variety of both successful and
unsuccessful empirical results have been obtained. There are also few commercial products that offer
genetic programming simulation software to the end users, investors. They will be evaluated in the
literature review section.
In this project we try to implement a software that provides a genetic programming simulation model for
the end user. In designing the software, we rely on the strong aspects of previously designed genetic
programming models to provide an efficient learning mechanism that can analyze historical price datasets
of different stocks and generate trade rules that can predict the future market directions. We also aim
towards developing a user-friendly and flexible software interface that can scan user-requested datasets
belonging to desired companies and produce explanatory informational output of simulation results to aid
the user in his/her prospective investment decisions.
The remainder of the report consists of the following sections:
Section 3 elaborates the overall aims and objectives of the project.
Section 4 sheds light on the background review of the project, describing the dynamics of the stock
market setting we work in, explaining the methodology of genetic programming and critically assessing
the existing literature on utilization of this technique in the stock market context.
Section 5 introduces the choice and justification of the design process we implemented in building the
software. The proposed algorithm of the program and our programming decisions are given afterwards.
Section 6 then explain the software implementation process, pointing out how the major components of
the software has been built.
Section 7 gives details about the testing methodology we adopted for debugging each component of the
software. The detected bugs and how they were overcome are mentioned.
Section 8 reveals the results and empirical findings we obtained from the running of our genetic
programming simulation software.
Finally in section 9, we discuss the conclusive remarks learned from the project and mention possible
future developments to the implemented software.
3. Aims and Objectives
The overall aim of this MSc project is to implement a piece of software that can allow the utilization of
genetic programming on finding technical trading rules in stock markets.
The first and foremost objective will be to create a genetic programming algorithm that will be
implemented on the historical price data input of chosen company stocks and discover optimized
solutions on finding trade rules/strategies that can generate profitable returns for the user. Thus, the
criteria to assess the program here will be on how efficiently the created genetic algorithm learns and
explores the stock price trends in the training phase while evolving a potential set of solutions.
The second objective will be to test the algorithm on how well the generated trade rules perform over the
future datasets of the analyzed stocks. For this a tester component for the software will be developed to
parse the solutions obtained from the algorithm and apply them over unseen future prices. Measures will
be taken to improve the algorithm for creating predictable solutions that can forecast future periods.
The third and last objective of the project is to design the frontend of the software for the end user so that
the it can provide an automated and user-friendly input handling and output generation for the whole
simulation. All attempts will be made to make the software as efficient as possible by providing
convenient ways for the user to interact with the graphical interface that will be built.
4. Background Review
Introduction to Background Review
This section of the report first explains the dynamics of trading in stock markets. It also touches upon the
reasons to why genetic programming simulations might prove useful for the investors of the market. Then
we explain the major structural aspects of genetic programming and discuss the existing literature on its
application to the stock market trading concept.
Dynamics of Trading in Stock Markets
Stock market is a subset of capital financial markets, in which companies that require additional funds
seek out investors who would be willing to invest their money on their business. (Chisholm, 2002) The
market acts a platform that connects sellers (companies) with buyers (investors). The trading in stock
markets are done through issuance of financial instruments called stocks. By holding these stocks, buyers
own a legal claim on the companies' earnings, so as companies engage in profitable investments,
stockholders also claim a share from their revenues and profits. (Drake & Fabozzi, 2010) The issued
stocks are open to availability of public purchase, so any individual or entity can become a buyer in the
market. (Becket & Essen, 2010) Some examples of stock markets include the New York Stock Exchange
(NYSE), London Stock Exchange (LSE) and the Toronto Stock Exchange (TSE).
The buyer in this environment is mostly concerned with the value of his/her stocks. The stock values are
reflected in the prices they are sold for in the stock market. Thus, as the price of a stock go up, so does the
value of the buyer's investment. Therefore, the intuitive goal of the buyer is to buy and keep the stocks
whose price is in an increasing movement. Oppositely, the buyer also should get rid of or not buy any
stocks that has a decreasing price movement.
There are many factors that affect the value of stocks in the real time trading environment. There may be
internal factors such as, the company might be making profitable investments that generate positive
returns on its revenue and hence, their stocks. There are also external factors such as, the stock investors
might be aggressively buying the stocks company issues and therefore generate additional revenue for
them, which in turn rises the value of the stocks for their buyers. (CITE!) As a consequence, the price
movements of stocks might be exposed to rapid and non-linear changes at any given time period. Figure
4.1 illustrates this condition for a 6-month stock price chart of a randomly selected company.
As seen in the diagram, the price of a stock undergoes through many changes in time, all of which are not
easy to explain and categorize. So the intuitive trading goal set for the buyer becomes very complex to
achieve in a real time trading environment. Hence, the investment problem demands a complex analysis
of the price trends that occur at such uncertain frequencies.
The concept of technical forecasting enters the problem at this point. Technical forecasting provides
investors with certain functions and model mathematical equations that would be applied to stock prices
to analyze the trends in stock price movements and aid the buying/selling decisions in the market. As
Becker et. al. (2007) describe, technical forecasting makes a quantitative analysis of stock markets to seek
signals of assets' return on investment (price/value) and generate model variables for the stockholders to
evaluate in deciding their trading actions.