+ All Categories
Home > Documents > [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA...

[IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA...

Date post: 12-Dec-2016
Category:
Upload: nuno
View: 215 times
Download: 1 times
Share this document with a friend
7
Abstract—This paper describes a new computational finance approach. This approach combines pattern recognition techniques with an evolutionary computation kernel applied to financial markets time series in order to optimize trading strategies. Moreover, for pattern matching a template-based approach is used in order to describe the desired trading patterns. The parameters for the pattern templates, as well as, for the decision making rules are optimized using a genetic algorithm kernel. The approach was tested considering actual data series and presents a robust profitable trading strategy which clearly beats the market, S&P 500 index, reducing the investment risk significantly. Index TermsGenetic Algorithms, Pattern Templates, Optimization, Financial Markets. I. INTRODUCTION HE domain of computational finance has received an increasing attention by people from both finance and computational intelligence domains. The main driving force in the field of computational finance, with application to financial markets, is to define highly profitable and less risky trading strategies. In order to accomplish this main objective, the defined strategies must process large amounts of data which include financial markets time series, fundamental analysis data, technical analysis data, etc. and produce appropriate buy and sell signals for the selected financial market securities. What may appear, at a first glance, as an easy problem is, in fact, a huge and highly complex optimization problem, which cannot be solved analytically. Therefore, this makes the soft computing and in general the computational intelligence domains specially appropriate for addressing the problem. Recently, several works [1] [2] have been published in the field of computational finance where soft computing methods are used for stock market forecasting, however, due to the complexity of the problem and the lack of generalized solutions this is undoubtedly an open research domain. The use of chart patterns is widely spread among traders as an additional tool for decision making, however, the problem in this case is to say how close enough should the market match a specified chart pattern to make a buy or sell decision. In this paper a new approach is presented in order to improve the quality of decision making by optimizing both the parameters for the pattern template and the parameters for the decision making rules. The optimization of the trading strategy is here carried out by a genetic algorithm kernel [3]. The proposed approach was tested considering a large period of time including different market trends and considering a sliding window for defining both training and testing periods. This paper is organized as follows: In Section II the pattern recognition approach based on a template description is analyzed outlining the parameters which will be subjected to an optimization process. Section III describes the overall trading optimization methodology. Section IV presents and discusses the selected case studies. Section V provides the conclusions of the paper II. PATTERN RECOGNITION BACKGROUND In recent years the area of chart patterns recognition has given rise to different detection methodologies applied to chart extracted from financial markets time series, Particularly, three main methodologies have been successfully applied. The first one is based on the application of templates [4-10], the second is used for the detection of perceptually important points [11- 14], and the third one uses positional rules for the most relevant points found on the second methodology. As in this paper the first methodology, template-based, was chosen to be optimized with an evolutionary optimization kernel, the remaining part of this section will describe the template-based approach outlining the critical parameters which will be subjected to optimization. A. Template-Based Methodology The template-based methodology, illustrated in fig. 1, consists of: first, defining the desired chart patterns templates in a matrix format, then, select the data points within a Trading with Optimized Uptrend and Downtrend Pattern Templates using a Genetic Algorithm Kernel Paulo Parracho, Rui Neves and Nuno Horta Instituto de Telecomunicações Instituto Superior Técnico Torre Norte, Av. Rodisco Pais, 1 [email protected]; [email protected]; [email protected] T 1895 978-1-4244-7835-4/11/$26.00 ©2011 IEEE
Transcript
Page 1: [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA (2011.06.5-2011.06.8)] 2011 IEEE Congress of Evolutionary Computation (CEC) - Trading with optimized

Abstract—This paper describes a new computational finance

approach. This approach combines pattern recognition

techniques with an evolutionary computation kernel applied to

financial markets time series in order to optimize trading

strategies. Moreover, for pattern matching a template-based

approach is used in order to describe the desired trading patterns.

The parameters for the pattern templates, as well as, for the

decision making rules are optimized using a genetic algorithm

kernel. The approach was tested considering actual data series

and presents a robust profitable trading strategy which clearly

beats the market, S&P 500 index, reducing the investment risk

significantly.

Index Terms— Genetic Algorithms, Pattern Templates,

Optimization, Financial Markets.

I. INTRODUCTION

HE domain of computational finance has received an

increasing attention by people from both finance and

computational intelligence domains. The main driving force in

the field of computational finance, with application to financial

markets, is to define highly profitable and less risky trading

strategies. In order to accomplish this main objective, the

defined strategies must process large amounts of data which

include financial markets time series, fundamental analysis

data, technical analysis data, etc. and produce appropriate buy

and sell signals for the selected financial market securities.

What may appear, at a first glance, as an easy problem is, in

fact, a huge and highly complex optimization problem, which

cannot be solved analytically. Therefore, this makes the soft

computing and in general the computational intelligence

domains specially appropriate for addressing the problem.

Recently, several works [1] [2] have been published in the

field of computational finance where soft computing methods

are used for stock market forecasting, however, due to the

complexity of the problem and the lack of generalized

solutions this is undoubtedly an open research domain.

The use of chart patterns is widely spread among traders as

an additional tool for decision making, however, the problem

in this case is to say how close enough should the market

match a specified chart pattern to make a buy or sell decision.

In this paper a new approach is presented in order to improve

the quality of decision making by optimizing both the

parameters for the pattern template and the parameters for the

decision making rules. The optimization of the trading strategy

is here carried out by a genetic algorithm kernel [3]. The

proposed approach was tested considering a large period of

time including different market trends and considering a

sliding window for defining both training and testing periods.

This paper is organized as follows: In Section II the pattern

recognition approach based on a template description is

analyzed outlining the parameters which will be subjected to

an optimization process. Section III describes the overall

trading optimization methodology. Section IV presents and

discusses the selected case studies. Section V provides the

conclusions of the paper

II. PATTERN RECOGNITION BACKGROUND

In recent years the area of chart patterns recognition has

given rise to different detection methodologies applied to chart

extracted from financial markets time series, Particularly, three

main methodologies have been successfully applied. The first

one is based on the application of templates [4-10], the second

is used for the detection of perceptually important points [11-

14], and the third one uses positional rules for the most

relevant points found on the second methodology.

As in this paper the first methodology, template-based, was

chosen to be optimized with an evolutionary optimization

kernel, the remaining part of this section will describe the

template-based approach outlining the critical parameters

which will be subjected to optimization.

A. Template-Based Methodology

The template-based methodology, illustrated in fig. 1,

consists of: first, defining the desired chart patterns templates

in a matrix format, then, select the data points within a

Trading with Optimized Uptrend and Downtrend Pattern Templates using a Genetic

Algorithm Kernel

Paulo Parracho, Rui Neves and Nuno Horta Instituto de Telecomunicações

Instituto Superior Técnico Torre Norte, Av. Rodisco Pais, 1

[email protected]; [email protected]; [email protected]

T

1895978-1-4244-7835-4/11/$26.00 ©2011 IEEE

Page 2: [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA (2011.06.5-2011.06.8)] 2011 IEEE Congress of Evolutionary Computation (CEC) - Trading with optimized

temporal sliding window, next, remove noise from data points,

finally, determine the fitness value by comparing the noiseless

data points with the defined chart pattern template.

In the next subsections each methodology step will be

addressed.

Time

Chart Pattern

Template

Template

Matrix

Time

Noiseless

Data Points

Noiseless Data

Matrix

Time

Original Data

Points

Time

Noiseless

Data Points

Templ

ate

Matrix

Noiseless

Data

Matrix Fitness

Template

Matrix

Generation

Noise

Reduction

Data

Matrix

Generation

Matrix

Cross

Multiplication

1

2

3

4

Figure 1 – Chart Pattern Recognition using Template-Based Methodology.

B. Template Matrix

Although the presented approach can be generalized, an

uptrend pattern is here considered for its relevance on practical

cases such as detecting the right market trend.

The chart pattern template must be described in a matrix

format, as illustrated in fig. 2. This matrix will be referred as

matrix “T”. The matrix size is selected based on the desired

template resolution, for practical purposes, in this case a 10x10

matrix was chosen. The cells values are selected within a range

where the maximum corresponds to the maximum fit, the

desired pattern, and the minimum corresponds to the minimum

fitness. In this case the selected range was from -1 to 1 and the

values for each cell were chosen heuristically where the sum of

the weights on each column must be 0.

-1 -1 -1 -1 -1 -1 -0.5 0 0 1

-0.5 -1 -1 -1 -1 -0.5 0 0 1 1

-0.5 -0.5 -0.5 -0.5 -0.5 0 0 1 1 1

-0.5 -0.5 0 0 0 0 1 1 0.5 0

0 0 0 0 0 1 1 0.5 0 0

0 0 0 0 1 1 0.5 0 0 0

0.5 0.5 0.5 1 1 0.5 0 0 -0.5 -0.5

0.5 0.5 1 1 0.5 0 -0.5 -1 -0.5 -0.5

0.5 1 1 0.5 0 -0.5 -1 -1 -1 -1

1 1 0 0 -0.5 -1 -1 -1 -1 -1

Figure 2 - Matrix Template (T) for the Uptrend Pattern.

C. Data Acquisition and Noise Reduction

After defining the desired template the data must be selected

from the whole data set, which is done by defining a sliding

window with a specific size and search for the desired window

moving the window n days on each iteration, as illustrated in

figure 3.

In order to avoid the spikes that usually appear in data

values a noise reduction procedure should be applied where a

defined percentage of points will be removed leading to a

smooth data curve.

Figure 3 – Sliding Window for Data Acquisition and Pattern Evaluation.

D. Data Matrix

The noiseless data obtained in the previous step must now

be described in a matrix format with a similar size to the

matrix “T”. Therefore, the new matrix will have the size 10x10

and will be referred as matrix “I”. Thus, for each sliding

window a new matrix “I” will be produced. The algorithm then

subdivides the sliding window in 10 equal groups, mapping

each of these groups in one of the columns of matrix "I". This

process will compress the time frame considered and maintains

the essential features of the original pattern. Each cell in the

new matrix is subjected to a factorization function, so that the

field values range between 0 and +1. Fig 4 illustrates the

generation of a matrix “I” for a sliding window of 60 days.

1896

Page 3: [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA (2011.06.5-2011.06.8)] 2011 IEEE Congress of Evolutionary Computation (CEC) - Trading with optimized

(a)

0.50

0.17 0.17

0.33 0.33

0.33 0.67 0.33

0.17 0.50 0.50 0.33 0.17

0.50 0.33 0.17

0.17 0.33 0.17 0.33 0.33 0.17

0.67 0.50 0.50

0.33 0.33 0.17

0.50

(b)

Figure 4 - (a) Temporal window of 60 days; (b) Matrix “I”.

E. Fitness

Once matrix “I” is obtained, a function of Fit is computed

based on a Cross-Multiplication of both matrixes.

(1)

Thus, the highest values for the Fit function will occur when

the image in matrix “I” is in highest conformance with matrix

“T”. For example, the presented case has a Fit of 7.5 out of 10.

III. OPTIMIZATION METHODOLOGY

Determining the optimal parameters for a trading strategy

based on chart pattern templates may be extremely profitable

but is clearly a huge task, particularly, when considering a

realistic case of using several templates and technical

indicators together. In this case, the search space rapidly rises

to unacceptable numbers and there is no analytical model to

solve the problem, therefore, evolutionary computation

appears at a natural solution.

A. Optimization Methodology Overview

The proposed optimization methodology, illustrated in fig.

5, is implemented with a three tier architecture (Data,

Application and Interface levels). The data level includes the

description of several chart templates, the market data which

includes updated historical data from most relevant financial

markets, and, finally, the technical indicators for the market

data. The application level is mainly composed by the

optimization kernel and the data acquisition system. The

interface level includes the selection of the templates, market

data and technical indicators to be considered during the

optimization process, the fitness function, and desired output

parameters.

Time

Re

lative

A

mp

litu

de

Chart Pattern

Template

Time

Re

lative

A

mp

litu

de

Chart Pattern

Template

Time

Re

lative

A

mp

litu

de

Chart Pattern

Template

Time

Rela

tive

Am

plit

ude

Original Data

Points

Time

Rela

tive

Am

plit

ude

Original Data

Points

Time

Rela

tive

Am

plit

ude

Original Data

Points

Figure 5 – Optimization Methodology Overview

B. Optimization Parameters

The selected optimization parameters, in this study, will be

the sliding window size, the noise removal percentage and two

additional parameters based on the fitness, FitBuy and FitSell.

The FitBuy is the limit that should be crossed up to produce a

buy signal, while the FitSell is the limit that should be crossed

down to originate a sell signal..

C. Optimization Kernel

The optimization kernel is based on a genetic algorithm

implementation where the previously referred optimization

parameters are the genes that composed the chromosome. The

optimization kernel evaluates each population element during

a predefined training period and considering a sliding window

which advances with a 1 day step. The population is rated, for

the examples presented in the next section based on the return

achieved on the evaluation/training period.

1897

Page 4: [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA (2011.06.5-2011.06.8)] 2011 IEEE Congress of Evolutionary Computation (CEC) - Trading with optimized

IV. RESULTS

In this section several case studies using the proposed

methodologies are presented. The application was tested in

real market conditions. Data was retrieved from 1998 to 2010

for three main stock indexes: S&P500, Dow Jones Industrial

Average and NYSE Composite Index. These indexes are

representative of the United States stock markets, the chosen

time span is large enough to embark a bull and a bear market.

Particularly, the training and testing period were, respectively,

from 1998 to 2004 and from 2005 to 2010.

Daily close price data is used because volatility is usually

lower near the end of day. Historical stock prices, adjusted for

dividends and splits, were gathered from yahoo finance.

A. Case Study I. Detection of the Uptrend

In this case study the application is going to find the uptrend

pattern. It gives the indication of an upward trend, which

develops because the demand for shares is larger than the

supply of shares. So the algorithm is based on the assumption

that once this pattern is detected, the upward trend will

continue to follow until at some point a reversal is detected.

Once this pattern is detected a buying signal is generated, and

when the uptrend eventually breaks the software will sell this

position.

In Figure 6 the evolution of the S&P500 from 2005 until

2010, testing period, is presented. Additionally two more

curves are depicted with the best and average GA run obtained

during the training period. For the first three years when the

market is in an uptrend the GA just follows the market. Then

the best GA sells its position around January 2008 and only

reenters the market in July 2009. As for the average GA, it

leaves the market on September 2007, only to reenter

temporarily from April to July 2008 and then finally from June

2009 onward. It is clearly shown that the algorithm also has

the capability of detecting bear markets and staying out of

them.

Figure 6 - Profitability Growth for three Strategies on S&P500.

In Figure 7 we have a histogram which demonstrates the

profitability distribution for 50 different executions of the GA.

The results show the algorithm is capable of producing

consistent and far better results than the B&H strategy, with

the results centered around 35% return and the B&H at almost

-5%.

Figure 7 - GA approach vs. B&H on S&P500.

Finally, Table 1 shows the results obtained for three stock

indexes. The robustness and superiority of the genetic

algorithm is evident by the returns presented.

Table 1 - Profitability for Different Stock Indexes.

Curve\Marke S&P500 Dow Jones NYSE

Average GA 36.92% 16.33% 10.02%

Best GA run 46.02% 30.54% 14.57%

Buy and Hold -4.69% 0.12% -1.41%

B. Case Study II. Mixing several Patterns

In this case study the pattern detection is going to be applied

to individual stocks belonging to the S&P 500 index. In the

previous case study only indexes were considered which

normally reflect a very low volatility environment, making it

easy to detect the upward trend and subsequence market exit in

the absence of it.

Analyzing financial assets with increased volatility took the

algorithm to perform an erratic behavior in buying/selling

decisions. The genetic algorithm typically chose values for

FitBuy and FitSell, in the training period that were not

consistent with the methodology we were trying to apply in our

stock investment, i.e., to buy in the presence of an upward

trend and to sell when it ended. In order to understand why this

was the case, in Figure 8 it is shown the return obtained for

different values of FitBuy and FitSell.

In Figure 8 profitability is highlighted on the vertical axis

while the different values used for FitBuy and FitSell are

depicted on the horizontal axes. The size used for the sliding

window was 60 days and the value of noise removal was 20%.

The tested values for FitBuy and FitSell considered all

possible combinations between -10 and +10, with variations of

0,5.

Given these results, and with the support of Figure 8, it

becomes apparent that there are certain areas were the returns

are good, some areas were the returns are negative and in some

places small changes in FitBuy or FitSell can move returns

from the positive area to the negative area. Therefore, the goal

is to find an area on this figure that transmits more robustness

to the optimization result.

1898

Page 5: [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA (2011.06.5-2011.06.8)] 2011 IEEE Congress of Evolutionary Computation (CEC) - Trading with optimized

Figure 8: Profitability obtained for the S&P500 with different values for

FitBuy and FitSell.

After analyzing the results of various financial assets and

market indexes, we came to the conclusion that restricting the

range of FitBuy between +6 to +8.5, and the range of FitSell

between -1.5 to +3.5 would make us gain a more robust

algorithm that could generate a more reliable investment

strategy with lower risk.

We also considered some additional chart patterns and

technical indicators that were made to support the decision of

buying or selling some financial asset, namely, the bull flag

and the breakout pattern. The bull flag pattern and the

breakout patterns, illustrated in figs 9 and 10, were used

simultaneously with the already existing technique for the

detection of the uptrend pattern. Results obtained from these

new additions to the algorithm are depicted below in a few

examples.

It was chosen a data set of the first 100 stocks, from the 500

stocks composing the S&P500 in alphabetic order. Each asset

has an historical price from 1998 onwards. Thus, we were only

interested in getting stocks with a history of prices whose

range was between January 1st of 1998 and April 21st of 2010,

which was the last trading day when this testing period took

place. The computing algorithm would then perform a training

period with a duration of approximately 7 years (January 1,

1998 to December 31, 2004), and a testing period with a

duration of 5 years and 4 months (between January 1, 2005 to

21 April 2010).

There was no major criterion in the decision that involved

picking up 100 stocks from S&P500. So, risk factors that

could have been associated with the chosen financial assets

were neglected, along with other characteristics like volatility

and the fundamental intrinsic value of the asset in question.

A trading simulation was performed on each of these

financial assets, using no criteria for their pre-selection. In this

way we can recreate a typical behavior that is found on newly

investors introduced to the stock market, which have no idea

of what and when to invest.

In the training period the algorithm does a maximum

number of 15 generations with no change on the profitability

of the best chromosome. That is, once we reach 15 generations

during the training period, between 1 January of 1998 and 31

December of 2004, with no improvement on the profitability

of the best chromosome, the algorithm will then jump to the

execution of the best chromosome that was found running it

from 1 January 2005 to April 21, 2010. This complete cycle is

executed 10 times for each financial asset.

Table 2 depicts the average results obtained for all of the

100 stocks that were retrieved from S&P500. We also

considered additional techniques involving the detection of

moving averages.

0.655 0,162 -0,428 -1 -1,38 -1,496 -1,415 -1,224 -1,5 1

1 0,584 0,048 -0,5 -0,908 -1,08 -1,07 -0,946 -0,875 1

1 1 0,524 0 -0,428 -0,674 -0,72 -0,668 -0,25 1

0.655 1 1 0,5 0,048 -0,248 -0,38 -0,39 0,375 1

0.31 0,584 1 1 0,524 0,162 -0,035 -0,112 1 0.524

-0.035 0,168 0,524 1 1 0,584 0,31 0,166 1 0.048

-0.38 -0,248 0,048 0,5 1 1 0,655 0,444 1 -0.428

-0.72 -0,674 -0,428 0 0,524 1 1 0,73 0,375 -0.904

-1.07 -1,08 -0,908 -0,5 0,048 0,584 1 1 -0,25 -1.38

-1.415 -1,496 -1,38 -1 -0,428 0,168 0,655 1 -0,875 -1.856

Figure 9 - Bull Flag Pattern.

-1.224 -1,224 -1,224 -1,224 -1,224 -1,224 -1,224 -1,496 -0,875 1

-0.946 -0,946 -0,946 -0,946 -0,946 -0,946 -0,946 -1,08 -0,25 1

-0.668 -0,668 -0,668 -0,668 -0,668 -0,668 -0,668 -0,674 0,375 1

-0.39 -0,39 -0,39 -0,39 -0,39 -0,39 -0,39 -0,248 1 1

-0.112 -0,112 -0,112 -0,112 -0,112 -0,112 -0,112 0,162 1 0.524

0.166 0,166 0,166 0,166 0,166 0,166 0,166 0,584 1 0.048

0.444 0,444 0,444 0,444 0,444 0,444 0,444 1 0,375 -0.428

0.73 0,73 0,73 0,73 0,73 0,73 0,73 1 -0,25 -0.904

1 1 1 1 1 1 1 0,584 -0,875 -1.38

1 1 1 1 1 1 1 0,168 -1,5 -1.856

Figure 10 - Breakout Pattern.

Table 2 - Average Return for Different Methodologies.

Methodology Fit

Buy

Fit

Sell

Noise

Removal

(%)

Sliding

Window

(days)

10 Runs

Average

Testing

Period

Uptrend

Pattern (1)

5,45 1,28 34,10% 54,4 35,57%

Uptrend

Pattern + Bull

Flag (2)

5,62 0,53 32,36% 49,4 42,36%

Uptrend

Pattern +

Breakout (3)

5,41 0,34 34,89% 50,1 45,89%

Uptrend Pat.

+ Breakout

Slim (4)

5,41 0,41 35,64% 50,5 41,96%

(1) Results obtained from applying the uptrend pattern to

the investment algorithm. The algorithm buys a position when

1899

Page 6: [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA (2011.06.5-2011.06.8)] 2011 IEEE Congress of Evolutionary Computation (CEC) - Trading with optimized

the uptrend pattern is present and will sell it once it is no

longer in the presence of it.

(2) This version of the algorithm includes the detection of

one more bullish pattern. In this particular case we are

considering the Bull Flag. The algorithm will make its actions

based on the presence of these two patterns.

(3) The behavior of the algorithm is tested considering the

breakout pattern instead of the bull flag.

(4) The breakout pattern is defined more precisely on the

algorithm’s graphic template. The 10x10 matrix has a finer

sample of the considered formation.

As can be seen on table 2 the different parameters obtained

for FitBuy, FitSell, Noise Removal and Sliding Window are

very similar.

C. Case Study III. Uptrend and Downtrend

In this section the use of the uptrend and downtrend patterns

with independent parameters is going to be evaluated.

So, we changed the system by adding more graphical

patterns that were responsible for the identification of the

downtrend formation and modified the chromosome under

optimization to contain two additional genes:

FitDescent - This new gene will be associated to the new

pattern templates characterizing the downtrend formation. This

way the algorithm will be more accurate in the search of this

particular graphic and will have a better precision when selling

an acquired market position.

Downtrend Sliding Window - Previously the algorithm

had only one sliding window available. Technical analysis

dictates that different pattern formations may have different

time periods associated with them.

So, it was added an additional sliding window responsible

for the detection of secondary graphical patterns, like the

downtrend, presented in Figure 11.

1 0,655 0,162 -0,428 -1 -1,38 -1,496 -1,415 -1,224 -0.998

1 1 0,584 0,048 -0,5 -0,908 -1,08 -1,07 -0,946 -0.776

0.723 1 1 0,524 0 -0,428 -0,674 -0,72 -0,668 -0.564

0.446 0,655 1 1 0,5 0,048 -0,248 -0,38 -0,39 -0.332

0.161 0,31 0,584 1 1 0,524 0,162 -0,035 -0,112 -0.11

-0.108 -0,035 0,168 0,524 1 1 0,584 0,31 0,166 0.112

-0.385 -0,38 -0,248 0,048 0,5 1 1 0,655 0,444 0.334

-0.682 -0,72 -0,674 -0,428 0 0,524 1 1 0,73 0.556

-0.939 -1,07 -1,08 -0,908 -0,5 0,048 0,584 1 1 0.778

-1.216 -1,415 -1,496 -1,38 -1 -0,428 0,168 0,655 1 1

Figure 11 - Downtrend Pattern.

The Downtrend pattern is a graphical formation used to

determine the moment we will no longer be in the presence of

the uptrend/horizontal tendency. Once this new pattern arises

the algorithm will sell its position and stay out of the market

during its presence.

Table 3 depicts the average results obtained for all of the

100 stocks that were retrieved from S&P500. We also

considered additional techniques involving the detection of

moving averages.

Table 3 - Uptrend Pattern + Downtrend Pattern

Methodology Fit

Buy

Fit

Descent

Noise

Removal

(%)

Sliding

Window

(days)

10 Runs

Average

Testing

Period

Uptrend Pat.

+ Downtrend

Pattern

5,45 6,96 27,70% 39,7/22,8 35,08%

In this new methodology the algorithm will acquire a buying

position once the uptrend pattern is detected by one of the four

matrixes that are used for the uptrend detection. On the other

hand the system will sell its position once it detects the

inversion/downtrend pattern. Sliding window sizes for both

patterns are different.

D. Case Study IV. Studying the impact of the Window size

Here, an additional study was conducted to establish the

influence that the sliding window size has on the results of the

algorithm. The values for the FitBuy and FitDescent are going

to stay fixed, with the size of the respective windows changing

in value.

The values used are presented on table 4. They were

obtained using as basis the best achieved chromosome during

the training period of the S&P500, between 1998 and 2004.

Since all the 100 stocks under study were retrieved from the

S&P500, it made sense to use these parameters during the

execution period of each one of them, from 2005 to 2010.

Table 4 – Resulting parameters found for the GA under S&P500.

GA Parameters Values

FitBuy 4.5

FitDescent 7

Noise Removal (%) 44,8

In Figure 12 the average return for the S&P500 for different

sizes of the sliding window is presented. On the horizontal axis

the FitSell and the FitDescent values range from 20 to 200. As

can be seen by the above figure better returns are normally

obtained from sliding windows with an average size of 100

days.

In Table 5 selected values for the window size are presented

with the annual return obtained for the period. As the window

size increases the return also increases. When using small

windows the application exits the investment too soon and

does not take full advantage of the detection of the pattern.

Next, in Figure 13 the return for the testing period is shown.

A commission of 3 basis points is applied to every trade, so we

can have a more realistic market condition that involves

transaction costs. As an example, 1bps is 1/100 of 1%, so for a

$50,000 trade there would be a commission of 15$ deducted

from the investment value.

1900

Page 7: [IEEE 2011 IEEE Congress on Evolutionary Computation (CEC) - New Orleans, LA, USA (2011.06.5-2011.06.8)] 2011 IEEE Congress of Evolutionary Computation (CEC) - Trading with optimized

Charging a commission had little impact on the final return

of the algorithm because each traded stock had a small number

of buy/sell operations along the 2005-2010 execution period.

As an example, for the 130/100 window size configuration, the

algorithm recorded only a total of 484 trading operations. This

means that each one of the 100 stocks under consideration had

an average of 4,84 buy/sell operations in a 5 year timespan,

which is less than 1 operation per year.

In Figure 13 it is apparent the time period in which the

genetic algorithm detects the downward trend, leaving the

market in late 2008. Afterwards the algorithm reenters the

market when it detects an upward trend.

Figure 12 - Average annual return obtained on S&P500 for different sizes

on both sliding windows for FitBuy and FitDescent.

Table 5 – Resulting parameters found for the GA under S&P500.

Window

Size

Return with

Reinvestment

Return

Annually

GA B&H

130/40 73.61% 51.37% 10.89%

130/60 74.1% 51.37% 10.95%

130/80 94.63% 51.37% 13.29%

130/100 103.49% 51.37% 14.25%

Figure 13 - Return value of the GA and B&H methodologies for all of the

100 stocks.

V. CONCLUSIONS

This document presents a new methodology where pattern

recognition techniques, based on a template approach, together

with an evolutionary computation technique are used to obtain

efficient trading strategies. The proposed approach was tested

with real data from world relevant stock markets. The achieved

results proof both the robustness and effectiveness of the

solution once it always perform better than B&H and assures a

high return rate

REFERENCES

[1] Georges Atsalakis, Kimon Valavanis, “Surveying Stock Market Forecasting Techniques – Part II: Soft Computing Methods”, Expert Systems with Applications: An International Journal, vol. 36, Issue 3, pp. 5932-5941, 2009.

[2] T.C. Fu, “A Review on Time Series Data Mining”, Engineering Applications of Artificial Intelligence: An International Journal, vol. 24, Issue 3, pp. 164-181, 2011.

[3] David E. Goldberg, "Genetic and Evolutionary Algorithms Come of Age", ACM, New York, NY, USA, 1994.

[4] Leigh W., Frohlich C.J., Hornik S., Purvis R.L. and Roberts T.L., "Trading With a Stock Chart Heuristic", Systems, Man and Cybernetics, Part A, IEEE Transactions on Volume 38, Issue 1, Jan. 2008 pp. 93 – 104.

[5] William Leigh, Naval Modani, Russell Purvis and Tom Roberts, "Stock market trading rule discovery using technical charting heuristics", Expert Systems with Applications, Volume 23, Issue 2, August 2002, pp. 155-159.

[6] William Leigh, Noemi Paz and Russell Purvis, "Market timing: a test of a charting heuristic", Economics Letters, Volume 77, Issue 1, September 2002, pp. 55-63.

[7] Leigh W., Paz M. and Purvis R., “An analysis of a hybrid neural network and pattern recognition technique for predicting short-term increases in the NYSE composite index”, Omega, vol. 30, pp. 69-76, 2002.

[8] William Leigh, Russell Purvis and James M. Ragusa, "Forecasting the NYSE composite index with technical analysis, pattern recognizer, neural network, and genetic algorithm: a case study in romantic decision support", Decision Support Systems, Volume 32, Issue 4, March 2002, pp. 361-377.

[9] Jar-Long Wang, Shu-Hui Chan, “Trading rule discovery in the US stock market: An empirical study”, Expert Systems with Applications: An International Journal, vol. 36, Issue 3, pp. 5450-5455, April 2009

[10] Jar-Long Wang and Shu-Hui Chan, "Stock market trading rule discovery using pattern recognition and technical analysis", Expert Systems with Applications, Volume 33, Issue 2, August 2007, pp. 304-315

[11] T.C. Fu, F.L. Chung, K.Y. Kwok and C.M. Ng, "Stock Time Series Visualization Based on Data Point Importance", Engineering Applications of Artificial Intelligence, Vol. 21, Issue 8, pp. 1217-1232, December 2008

[12] T.C. Fu, F.L. Chung, R. Luk and C.M. Ng, "Representing Financial Time Series Based on Data Point Importance", Engineering Applications of Artificial Intelligence, Vol. 21, Issue 2, pp. 277-300, March 2008

[13] T.C. Fu, F.L. Chung, R. Luk and C.M. Ng, "Stock Time Series Pattern Matching: Template-based vs. Rule-based Approaches", Engineering Applications of Artificial Intelligence, Volume 20, Issue 3, April 2007, Pages 347-364

[14] T.C. Fu, F.L. Chung, R. Luk and C.M. Ng, "Preventing Meaningless Stock Time Series Pattern Discovery by Changing Perceptually Important Point Detection", The 2nd International Conference on Fuzzy Systems and Knowledge Discovery (FSKD 2005), pp. 1171-1174, Changsha, China, 27-29 August 2005

1901


Recommended