1-s2.0-S0957417411007433-main
1-s2.0-S0957417411007433-main
1-s2.0-S0957417411007433-main
a r t i c l e i n f o a b s t r a c t
Keywords: The management of financial portfolios or funds constitutes a widely known problematic in financial
Stock trading markets which normally requires a rigorous analysis in order to select the most profitable assets. The pre-
Portfolio composition sented paper proposes a new approach, based on Intelligent Computation, in particular genetic algorithms,
Technical analysis which aims to manage a financial portfolio by using technical analysis indicators (EMA, HMA, ROC, RSI,
Evolutionary computation
MACD, TSI, OBV). In order to validate the developed solution an extensive evaluation was performed,
Optimization
comparing the designed strategy against the market itself and several other investment methodologies,
such as Buy and Hold and a purely random strategy. The time span (2003–2009) employed to test the
approach allowed the performance evaluation under distinct market conditions, culminating with the
most recent financial crash. The results are promising since the approach clearly beats the remaining
approaches during the recent market crash.
Ó 2011 Elsevier Ltd. All rights reserved.
1. Introduction stocks and markets gives appropriate signals about the market
future performance. This premise constitutes the basis of technical
The fast technology evolution together with the massive analysis which simply tries to analyze the securities past perfor-
evolvement of financial markets in modern societies leads, mance in order to evaluate investments at the present time. This
nowadays, to an increasing interest to the field of computational philosophy relies on three bases (Murphy, 1999); the fact that mar-
finance. ket action discounts everything, the fact that price moves in trends,
This field is becoming popular among computer scientists, espe- and that history tends to repeat itself. These considerations allow,
cially to computational intelligence specialists who try to combine through the study of charts and financial data, the recognition of
elements of learning, evolution and adaptation in order to create which way the market is more likely to go. Despite the fact that
intelligent software. In particular, subjects such as neural net- technical analysis is becoming widely used, there are still some
works, swarm intelligence, fuzzy systems and evolutionary com- criticisms to this perception on the market evolution. For instance,
putation are becoming extremely notorious on market’s domain. Burton Malkiel (Malkiel, 1973) stated that the ‘‘past movement or
The mentioned techniques can be applied to financial markets in direction of the price of a stock, or overall market cannot be used to
a variety of ways; as to predict the future movement of a stock’s predict its future movement’’. His findings become popular, lead-
price, or to optimize a collection of investment assets, such as a ing to a new investment theory called The Random Walk Theory
fund or a portfolio. This innovation is of special importance due where the author stipulates that if we cannot beat the market, then
to the high volume of securities (financial instruments) involved, the best investment strategy we can apply is Buy and Hold in
normally, it is very hard for a simple investor to optimize his prof- which an investor buys stocks and holds them for a long period
its without requiring the skills of financial markets specialists. The of time, regardless of market fluctuations. For the technical com-
goal of this work is to provide an application which tries to par- munity, this idea of purely random movements of prices is totally
tially replace those specialists in order to help an investor or an rejected, and more recent studies (Lo & MacKinlay, 2001; Park &
investment company to achieve a significant profit on buying Irwin, 2007) try to evidence their beliefs. For instance, in (Lo &
and selling (trading) financial instruments. In order to apply such MacKinlay, 2001) the author demonstrated the validity of technical
procedures we must accept that the historical data related to analysis using more than seventy technical indicators which
showed that market movements can be predicted at a certain
degree. Also, if we consider the price movement as unpredictable,
how can we explain that price moves in trends? If we observe sev-
⇑ Corresponding author. eral stock charts considering a predefined period we can easily de-
E-mail addresses: rui.neves@lx.it.pt (R. Neves), nuno.horta@lx.it.pt (N. Horta). tect an uptrend or a downtrend.
0957-4174/$ - see front matter Ó 2011 Elsevier Ltd. All rights reserved.
doi:10.1016/j.eswa.2011.04.216
A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085 14073
The presented paper provides a detailed discussion on a new a technical analysis of the market. In this work, a pure technical
approach for intelligent portfolio management. The paper is struc- analysis (Murphy, 1999) methodology was employed. A technical
tured as follows: Section 2 addresses the theory behind the devel- analyst believes that market action, namely, the volume of transac-
oped work, namely the concepts of financial portfolio, portfolio tions and the securities prices include all the fundamentals that
management, and technical analysis. Also, in this section, it is given can possibly affect market’s price; political, economical, or psycho-
a brief overview about different methodologies which can be used logical. The applied strategies based on technical analysis normally
to address the portfolio management problematic. Section 3 illus- embody a set of technical indicators which try to give a future per-
trates the system architecture. Section 4 proposes the validation spective of market development according to what is visible on
procedure used to evaluate the developed strategy. Section 5 sum- price charts. A technical indicator consists in a formula that is nor-
marizes the provided document and supplies the respective mally applied to stock’s prices and volumes. The resulting values
conclusion. are plotted and then analyzed in order to offer a perspective on
price evolution. More specifically, a technical indicator tries to cap-
2. Related work ture the behavior and investment psychology in order to determine
if a stock is under or overvalued. In Section 3, several technical
To get a better understanding about the underlined problem indicators will be discussed and illustrated.
and the existing solutions, some of the fundamental concepts
and tools related to the financial portfolio composition are ex- 2.4. Automatic portfolio management approaches – overview
plained in the following subsections.
In respect to the solutions already developed to address the
portfolio management problem, most of them focus on a passive
2.1. Financial portfolio
management approach by using the Mean–Variance model
(Markowitz, 1972) proposed by Harry Markowitz. The author is
A financial portfolio (Maginn, Tuttle, McLeavey, & Pinto, 2007)
pioneer in the Modern Portfolio Theory (MTP) after analyzing the
consists in a group of financial assets, also called securities or
effects related with risk, correlation and diversification over the ex-
investments, such as stocks, bonds, futures, contract for difference
pected returns of investment portfolios. After completing his study,
(CFDs), or groups of these investment vehicles known as exchange-
Markowitz concluded that rational investors should diversify their
traded-funds (ETFs). In order to construct a portfolio, it is capital to
investments, in order to reduce the respective risk and increase the
define investment objectives that should focus on a certain and ac-
expected returns. The author’s assumption focus on the basis that
cepted degree of risk, i.e. the chance of incurring in a loss.
for a well diversified portfolio, the risk which is assumed as the
The core of this work is related to portfolio management, the act
average deviation, from the mean, has a minor contribution to
of deciding which assets need to be included in the portfolio, how
the overall portfolio risk. Instead, it is the difference (covariance)
much capital should be allocated to each kind of security and when
between individual investment’s levels of risk that determines
to remove a specific investment from the holding portfolio. During
the global risk. Based on this assumption, Markowitz provided a
this process, it is required to take into account the investor’s pref-
mathematical model which can be easily solved by metaheuristics
erences since some investors are more willing to accept a specific
such as Simulated Annealing (SA), Tabu Search (TS) or genetic algo-
degree of risk than others, hoping that way to achieve better
rithms (GA).
returns.
Generally, solutions (Chang, Meade, Beasley, & Sharaiha, 2007;
Cura, 2009; Schaerf, 2002), based on this model, focus their goal
2.2. Portfolio management on optimizing a single-objective; the risk inherent to the portfolio,
in order to determine the optimal portfolio composition and the
As it was already mentioned, the goal of this work is concen- weights assigned to each of the chosen stocks. Besides this sin-
trated on the automatic management of a portfolio. So, it is impor- gle-objective formulation, other approaches (Branke, Schecken-
tant to understand that we can apply two forms of management bach, Stein, Deb, & Schmeck, 2009; Streichert, Ulmer, & Zell,
(Maginn et al., 2007): 2003) try to optimize simultaneously two conflicting objectives,
the global risk and the expected returns of the securities within
Passive management in which the investor concentrates his the portfolio.
objective on tracking a market index. This is related to the idea Besides the referred works which mainly generate a diversified
that it is not possible to beat the market index, as stated by the portfolio maintaining it for a specific set of time, Aranha and Hito-
Random Walk Theory (Malkiel, 1973). More concretely, a pas- shi (Aranha & Hitoshi, 2008; Aranha & Iba, 2007, 2009) provided a
sive strategy aims only at establishing a well diversified portfo- very interesting active management approach, by coupling the
lio without trying to find under or overvalued stocks. Markowitz’s model with a modeling cost mechanism, responsible
Active management in which the main goal of the investor con- for rebalancing the portfolio trough time while, at the same time,
sists on outperforming an investment benchmark index, buying minimizing the transaction costs. In their works, a completely dif-
undervalued stocks and selling overvalued ones. ferent portfolio representation is used, based on a tree structure,
which allowed them to obtain very interesting results.
In the case of the work here described, the purpose is to adopt Although Markowitz’s model is widely used to design the port-
an active management approach by using technical analysis indi- folio optimization problem, other models can also be considered.
cators and evolutionary computation techniques. For instance, Black and Litterman (Black & Litterman, 1992) sug-
gested a new formulation, the Black–Litterman model. In their work
2.3. Technical analysis they propose means of estimating expected returns to achieve bet-
ter-behaved portfolio models. The designed model is very similar
When defining a financial fund or portfolio the goal is to pick to the Markowitz’s one, the main difference is concentrated on
the best potential assets within the market in order to minimize the calculation of the expected returns which generates portfolios
losses and maximize returns. There are several ways to perform considerably different when using the original model. According to
a reasonable evaluation of the market to select potential profitable the authors their new design tries to rectify some of the flaws pre-
securities. Usually, investment analysts perform a fundamental or sented by Markowitz’s model.
14074 A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085
Table 1
An overview over different approaches on portfolio optimization.
Approach Date Metaheuristic Additional Constraints Portfolio analysis Portfolio Evaluation function
features representation
(Arnone, Loraschi, & 1995 Genetic Distributed — Downside risk Unknown Lambda trade-off function
Tettamanzi, 1993) algorithm version framework
(Schaerf, 2002) 2003 Simulated — Floor Markowitz Real value Minimization portfolio’s variance
Annealing Ceiling array maximization portfolio’s return
Cardinality structure
Turnover
Trading
(Ehrgott, Klamroth, & 2004 Genetic Multi criteria Cardinality Markowitz’s model Predefined Minimization portfolio’s variance
Schwehm, 2004) algorithm decision model Round-Lots decomposition structure maximization portfolio’s return
(Cura, 2009) 2008 Particle Swarm — Floor Markowitz Hybrid Lambda trade-off function
Optimization Ceiling structure
Cardinality
(Aranha and Hitoshi, 2008 Genetic — — Markowitz Tree structure Sharpe ratio
2008) algorithm
(Aranha and Iba, 2009 Genetic Memetic Multi-Period Markowitz Tree structure Sharpe ratio
2009) algorithm algorithm consideration
(Wagman, 2003) 2003 Genetic — Cardinality Technical rules Predefined Maximization of technical rules
programming structure satisfaction
(Yan et al., 2008) 2008 Genetic — Cardinality 1 technical rule + 18 Predefined Sharpe ratio
programming Multi-Period fundamental indicators structure
A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085 14075
quently, picking the best stocks for defining a financial portfo- All the financial data relative to the former index was
lio. Afterwards, the portfolio is updated and evaluated during downloaded through the Yahoo Finance Database (Yahoo! Inc,
the training period in order to classify the attractiveness of 2010). The complete retrieving process can be described as
the current classifier equation in terms of its performance on following:
the end of the considered time period.
When the GA converges in a final solution, the system executes Specify the desired index. Each index is identified with a unique
again the investment simulator system, but to the current date keyword. For instance, the Dow Jones Industrial Average is tagged
period, in order to provide the recommended portfolio taking with the acronym DJI.
into account today’s date. After defining the target index, the download process is exe-
Every week the Investment Simulator is again executed to cuted and a single file containing the tickers (specific group of
update the current portfolio, adding new positions or closing letters representing a particular security) of all companies com-
former ones. From time to time, the GA process is repeated so posing the previously defined index, is stored. The second pro-
that a new classifier equation is determined considering the cess consists on downloading all the historical data, from a
most recent data. specific date until today’s date for each of the previously
acquired companies. The designer has the possibility of indicat-
3.3. Data layer ing the desired data period through a single parameter; daily,
weekly, or monthly. Within this download process, the storage
The data layer is responsible for managing financial data. Its functionality is executed, responsible for defining csv files with
behavior is decomposed in two distinct modules, the financial data the desired financial data. Each record within these stored files
processing module and the technical rules module. has the following configuration:
3.3.1. Financial data processing module Date Open High Low Close Volume Adj. Close
This module is accountable for processing all the financial data
which is of primary use on the developed application. In order to
provide to the system the ability of generating real-life portfolios, where:
it is necessary to first download a complete history of all the avail-
able data on distinct markets. The process of retrieving all the his- Date: The date record, using the format ‘‘dd-mm-yyyy’’.
torical data was performed just once. Afterwards, it is only Open: The opening price in which the security was traded dur-
necessary to update the database with new available information. ing a specific date.
In respect to the considered data, the Dow Jones index was High: The highest price in which the stock was traded during a
used: specific date.
Low: The lowest price in which the equity was traded during a
The DJI, Dow Jones Industrial Average Index (Dow Jones Indexes, specific date.
2010), which contains the stock prices of 30 of the largest held Close: The closing price in which the asset was traded during a
companies in the United States. specific date.
14076 A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085
Volume: The number of shares traded in a security during a Taking into account all the historical data, for each period a spe-
specific date. cific score was assigned taking into account the following technical
Adj. Close: The adjusted closing price in which the stock was indicators and defined rules.
traded during a specific date.
After the complete historical data has been downloaded, 3.3.2.1. Extensibility and technical rules module implementation. As
when the application is again executed, the update action stated before, the intent was to mix different kinds of technical
is invoked, which corresponds to a specific method account- indicators: oscillators and trend following mechanisms. In order
able for processing all companies’ files and for each one to respect that guideline, the indicators employed were the Expo-
identifying the last record, in particular the date of the last nential Moving Average (EMA), the Hull Moving Average (HMA),
available record. After this processing phase, each company’s the Rate of Change (ROC), the Double Crossover method, the Relative
file is updated; the new necessary records are inserted. Strength Index (RSI), the Moving Average Convergence Divergence
Notice that each data file is ordered from the oldest date to (MACD), the True Strength Index (TSI), and the On Balance Volume
the most recent one. (OBV). Notice however, that is possible to easily extend the devel-
oped solution with more technical indicators. The algorithm is
3.3.2. Technical rules module adapted for any technical indicator, the only requirement is to
One of the major problems faced on portfolio management is implement the desired indicators and define the respective rules.
the right choice of assets. However, technical indicators can be On adding more indicators, the confirmation of a possible buy or
used to give a future perspective on its behavior in order to deter- sell signal is possibly more accurate, improving the results of the
mine the best choice. So, in order to classify each asset within the designed solution. The parameters assigned to each technical indi-
market, a set of rules based on technical indicators was employed. cator can also be altered to any value desired by the designer.
Nevertheless, there are several problems that can show up In the following paragraphs, the reader can have an insight on
when using technical indicators. First, there’s not a better indica- the selected indicators as well as the respective classification rules.
tor, the indicators should be combined in order to offer us different
perspectives. Sometimes a technical indicator gives false signals, so 3.3.2.2. Exponential Moving Average (EMA). The Exponential Moving
our best option is to combine different technical indicators. Second, Average (EMA) (Murphy, 1999) is a trend following indicator. The
a technical indicator always needs to be applied to a specific time goal of this device is to identify that a trend has begun, or it is fin-
span, it can be 10 days, 50 days, more or less. Determining the best ishing its cycle. In order to accomplish it, the EMA averages the
time window is a complex choice, in this case the selected time price data, in order to produce a smooth line which can be easily
window considered was the one proposed by the technical analysis perceived, in contrast to the irregular curve signaling the prices.
experts, for each of the used indicators. There are several kinds of moving averages; the exponential one
Regarding the GA aspects, the algorithm can be applied in sev- assigns more weight to the most recent data in order to give more
eral ways, as to determine the best time span, for instance, Ferná- importance to it. Its formula can be defined as following:
ndez-Blanco et al. (Bodas-Sagi, Fernández, Hidalgo, Soltero, &
Risco-Martín, 2009; Férnandez-Blanco, Bodas-Sagi, & Hidalgo, 2 2
EMAt ðnÞ ¼ EMAt1 ðnÞ ð1 Þ þ Xt ð1Þ
2008) applied an EA to determine the best settings for the MACD nþ1 nþ1
and RSI indicators. However, in this work the algorithm is applied Where:
in the context of obtaining the best model to classify the assets, an
optimal balance between different technical indicators. Since only n is the length of the moving average.
one indicator cannot possibly be enough, we try to find which were X corresponds to the stock’s price.
the best indicators to use in the past to form a basket of securities t defines the considered period (day, week, or month).
and subsequently, pick the most attractive assets.
In this work several technical indicators were applied to find Based on this indicator, the rules, presented in Table 2, were
attractive stocks in the market. The indicators were chosen in order defined.
to build a basket of different types of technical indicators such as Fig. 3 provides an example of the EMA line. As can be seen, it de-
momentum oscillators and trend following devices: fines a smoothing curve which can be easily analyzed, in contrast
to the zigzag performed by the stock’s prices.
A trend following indicator tries to identify trends in the mar-
ket. A trend represents a consistent change in prices, the inves- 3.3.2.3. Hull Moving Average (HMA). Like the EMA, the Hull Moving
tors’ expectations. Average (HMA) (Hull, Hull Moving Average, 2004), illustrated in
A momentum based indicator tries to measure the velocity of Fig. 4, tries to identify the prevailing market trend. However, it
directional price movement in order to identify the speed/ can define a smoother curve and can follow the price graph much
strength of a price movement and the enthusiasm of buyers more closely, reducing the lag present on its predecessor moving
and sellers involved in the price development. average. Its formula is calculated as following:
pffiffiffi
For each technical indicator calculated for each period (day, HMAt ðnÞ ¼ WMAt ðfloorð nÞÞ ð2Þ
week, or month) in the data set, a score was assigned. Four distinct n
scores were used: of 2 WMAt floor WMAt ðnÞ
2
Very Low Score: Assigns – 1.0 points, indicates a strong sell/ Where:
short signal.
Low Score: Assigns – 0.5 points, indicates an underperformed n is the length of the moving average.
signal, potentially to sell or to go short. WMA corresponds to the weighted moving average.
High Score: Assigns – 0.5 points, indicates a reasonable buy t defines the considered period (day, week, or month).
signal.
Very High Score: Assigns – 1.0 points, indicates a strong buy What this formula says is that the Hull moving average is the
signal. weighted moving average of length square root n of the difference
A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085 14077
between two weighted moving averages one of length n/2 and the false signals) and a longer moving average which has a longer
other n. In this difference the weighted moving average of length n/ lag, although it can produce better trend signals. In this work,
2 has 2 times the value of the weighted moving average of n. the couple was made between an exponential moving average of
For the HMA indicator, the rules, presented in Table 3, were five weeks and one with twenty weeks.
defined. For the Double Crossover method, the rules, presented in
Table 4, were defined.
The picture below demonstrates how we can apply the Double
3.3.2.4. Double Crossover. The Double Crossover (Murphy, 1999),
Crossover procedure.
illustrated in Fig. 5, method is characterized by using two distinct
moving averages to generate market signals. Normally, it is made a
couple between a shorter moving average (more sensible to the 3.3.2.5. Rate of Change (ROC). The Rate of Change (ROC) (Murphy,
market signal and consequently faster, although it can produce 1999), illustrated in Fig. 6, ratio presents the percentage difference
14078 A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085
between the current closing price and the price n time periods ago. 3.3.2.6. Relative Strength Index (RSI). The Relative Strength Index (RSI)
On doing so it allows us to measure how rapidly the price of a spe- (Murphy, 1999), illustrated in Fig. 7, indicator is a momentum oscil-
cific stock is moving. If the price is rising or falling too quickly it lator used to compare the magnitude of a stock’s recent gains to the
will probably indicate overbought or oversold conditions. Its for- magnitude of its recent losses, in order to determine overbought or
mula can be specified as following: oversold conditions. The formula used on its calculation is:
X t X tn 100
ROC t ðnÞ ¼ 100 ð3Þ RSIt ðnÞ ¼ 100 ð4Þ
X tn 1 þ RSðnÞ
Where: Where:
For the ROC indicator, the rules, presented in Table 5, were When calculated, the RSI line forms a signal between 0 and 100,
defined. which specifies determined overbought or oversold conditions
A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085 14079
when its value is above or below specific levels. For the RSI indica- IFX t < X t1 ! OBV t ¼ OBV t1 V t ð9Þ
tor the rules, presented in Table 6, were defined.
IFX t ¼ X t1 ! OBV t ¼ OBV t1 ð10Þ
3.3.2.7. Moving Average Convergence Divergence (MACD). The
Moving Average Convergence Divergence (MACD) (Murphy, 1999) Where:
indicator constitutes one of the most reliable indicators within
the market. It is a trend following momentum indicator that Xt corresponds to the stock’s price on period t.
exhibits the relation between two distinct moving averages. Vt is the volume referent to period t.
Essentially, it defines two lines; the MACD line which corre-
sponds to the difference between a 26-week and 12-week EMA The OBV always takes a direction, a rising OBV line indicates
and a trigger line which corresponds to an EMA of the MACD that the volume is heavier on up days, confirming a possible up
line. The difference between the former lines allows us to obtain trend.
a histogram which can be easily analyzed and offering us per- For the OBV indicator, the rules, presented in Table 8, were
spectives on price evolution. defined.
n corresponds to the number of periods considered for the trig- the Investment Simulator Module, accountable for simulate the port-
ger line. folio management during the training/validation.
The rules, presented in Table 9, were defined for the former 3.4.1. GA Optimization Module
indicator. Since a GA is composed by several components we will start to
describe how each component of the algorithm was defined.
3.4. Business logic layer 3.4.1.1. Chromosome representation. Starting with the chromo-
some representation, an individual in the population is repre-
This layer is accountable for defining the optimizer techniques sented by a real valued array structure where each element
and correspondent representation in order to result on a classifier corresponds to the weight, importance given to a specific tech-
system capable of defining models to score the different assets nical rule within the classifier equation. Besides the described
within the market. The layer is structured on two distinct modules; weights, assigned to each technical rule, four bound values are
Optimization Module, responsible for the optimization process, and also employed to define the necessary score that an asset needs
A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085 14081
Table 2 Table 6
Rules developed for the EMA indicator. Rules developed for the RSI indicator.
Table 3 Table 7
Rules developed for the HMA indicator. Rules defined for the MACD indicator.
Table 4 As we can observe, from the previous table, each rule has a spe-
Rules developed for the Double Crossover method. cific weight within the classifier model. The classifier is given by
EMA (5) – EMA (20) the following equation:
Very Low Score EMA(5) crosses below the EMA(20) line X
N
Low Score Both EMAs are decreasing W i :ScoreðX; iÞ ð14Þ
High Score Both EMAs are rising i¼0
Very High Score EMA(5) crosses above the EMA(20) line
0 6 Wi 6 1 ð15Þ
Table 5 X
N
Rules developed for the ROC indicator. 06 Wi 6 1 ð16Þ
i¼0
ROC (13)
Very Low Score ROC line crosses below 0 Where:
Low Score Bullish divergence – ROC increasing, price decreasing
High Score Bearish divergence – ROC decreasing, price increasing
Wi is the weight/importance assigned to the technical rule i.
Very High Score ROC line crosses above 0
Score(X, i) corresponds to the score given by the technical rule i
to stock X.
to obtain so it can adopt a long or a short position within the After the optimization performed by the algorithm, resulting on
portfolio, or to close the former position. In order to get a better a classifier equation, where a set of technical indicators are cor-
understanding on the considered representation, presented in rectly balanced, all the assets within the market are classified, as
Table 10. illustrated in Fig. 11. The stocks whose classification is higher than
14082 A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085
Table 8 Week 1: Given the Score (X, i) which represents the score given
Rules developed for the OBV indicator. to X on a specific period, by the indicator i, and the chromosome
OBV values, we can easily calculate the punctuation given to the
Very Low OBV is falling simultaneously with price indicating a clear contemplated assets. Considering the obtained performance,
Score down trend only the securities A and C present a higher classification than
Low Score OBV is decreasing and price is rising indicating a possible the value given by the Buy Limit Gene, defining this way the
uptrend breakout portfolio composition;
High Score OBV is rising and price is declining indicating a possible
downtrend breakout
Week 2: Given the previous explanation; securities B and D are
Very High OBV is rising simultaneously with price indicating a clear up included on the basket. Since the position C presents a classifi-
Score trend cation lower than the Close Buy Gene, in opposition with the
security A; position C its closed and A is maintained.
Week 3: Considering the former processes, stocks B and D com-
Table 9 pose the final portfolio.
Rules specified for the TSI indicator.
Notice, however, that the proposed example only represents a
TSI (25,13,7)
short view on the considered strategy. The developed investment
Very Low Score TSI crosses below trigger on overbought region (25)
process considers several technical indicators and applies stop
Low Score TSI is declining between the 25 and 25 levels
High Score TSI is rising between the 25 and 25 levels techniques in order to avoid sudden losses not predicted by the ap-
Very High Score TSI crosses below trigger on oversold region (25) plied algorithm.
As you can observe from the previous equation, the number of The complete management process is the following:
mutations largely depends on the number of total variables consid-
ered by the algorithm. Notice, however, that one single individual – The first step consists on applying 50% of the available budget
was discarded, as you can see from the minus one within the equa- on generating the initial portfolio using the equation given by
tion. The purpose of this restriction is to maintain the best individ- the algorithm.
ual in the current population, in each generation of the algorithm. – In each new week, during the period of validation or training,
This technique is normally referred as Elitism. the portfolio is updated using the following rules:
o If there are positions in the portfolio presenting a loss of 10%
3.4.1.4. Crossover. Considering the crossover operator, different or higher, the current position is immediately closed. This
types of crossover operators were implemented, in particular, the condition is an insurance to avoid an unexpected crash on
Single Arithmetic Recombination, the Whole Arithmetic Recombina- the company.
tion, and the One-Cut Point Crossover method, contemplating the o If there is a position which presents a score indicating a pos-
generation of two offsprings. After performing a rigorous testing sible close and it has already given profit, the position is
on the algorithm convergence, it was concluded that the one-cut closed.
point methodology allowed us to obtain the best results for the o If there are stocks in the market who present a classification
represented chromosome. possible to add, and the portfolio has not achieved its maxi-
mum size, new positions are formed within the portfolio. The
3.4.1.5. Constraints. One of the major problems presented by the remaining 50% of the budget is used for considering these
defined chromosome concentrates on the restrictions over the dif- new positions.
ferent weights assigned to the stipulated technical rules.
A trivial way on handling an inequality constraint such as the
former one consists on applying a death penalty function (Coello, 3.5. Presentation layer
1999), discarding infeasible individuals within the population.
Although it seems an extremely basic approach, this methodology The presentation layer is responsible for the application inter-
has as major problem the fact of not exploring any information face. Since a detail explanation of this layer is out of scope for this
from the infeasible individuals, in order to guide the search more paper, just a brief description on the necessary inputs, to be spec-
effectively. To surpass this problem, we have employed a simu- ified by the average user, is given:
lated artificial immune system (Coello & Cortés, 2001) which pro-
vides an efficient way of guiding the search, taking into account the Budget: The capital available to invest.
information generated by the infeasible individuals. Besides the Max Size: The maximum number of assets included on the
fact of being easy to implement, this strategy is also very effective desired portfolio.
on the proposed goal of exploring information gathered by the non Short Selling: This parameter is used for specifying if short sell-
feasible genes. Very generically, the algorithm maintains in each ing is allowed or the user just want to adopt long positions.
generation a population of infeasible individuals designated as Transaction Costs:Used for the consideration of transaction
antibodies which suffers the same kind of evolution of the main costs. This parameter is used to include the commission costs
population. However, the evaluation function is much easier which involved on buying or selling shares.
allows us to rapidly execute the convergence process within this
smaller population. This convergence procedure corresponds to
the process of executing a genetic algorithm inside the main genet- 4. System validation
ic algorithm. The principle behind this algorithm corresponds to
the Negative Selection Model which tries to capture the behavior In this section the validation approach for evaluating the devel-
of the human immune system on knowing what is really part of oped system is described.
the human system, and what is not. In order to validate the designed application during its develop-
ment, a Backtesting (Ni & Zhang, 2005) strategy was employed.
3.4.1.6. Evaluation function. In order to evaluate each individual
within the population, so the algorithm can pick the best ones
for reproduction, and consequently, converge on an optimal solu- Table 11
Case study - Configuration.
tion, the Return On Investment (ROI) function was applied. The
ROI is used to evaluate the efficiency of different investments dur- Parameter Value
ing a specific period of time. Market All stocks from DJI
As you can see, a simple objective was considered for evaluating Period 01/01/03 – 31/06/09
each solution, i.e., the goal of the algorithm is to maximize the ROI. Budget 100 000 USD
Maximum size portfolio 10
However, the solution could be easily extended with a multi-objec-
Short selling? TRUE
tive consideration, where the goal was to optimize simultaneously Commissions 0.02 / Share Minimum Fee: 14.00 USD
two conflicting objectives; the ROI and the risk involved, which Number of executions 100
could be measured by the volatility of returns, for instance.
module is used by the genetic algorithm, in order to classify each Population size 64
chromosome and performing test/real-life simulations. There are Mutation rate (%) 10
Generations 350
several specifications that need to be concretely defined over this Trunc. Threshold (%) 50
Investment Simulator module. As already stated the IS will use a Sliding window 6 months/6 months
specific equation to classify the assets within the market.
14084 A. Gorgulho et al. / Expert Systems with Applications 38 (2011) 14072–14085
4.1. Case study – description ing random positions, and picking new random assets from the
market, to add to the already existent portfolio. Both long and
In order to validate the designed solution, a critical time interval short positions are considered.
including both bullish and bearish trends, the DJI between 2003
and 2009, was considered. Moreover, the proposed approach is
compared against the B&H and a random investment strategy. 4.2. Case study – parameters setup
Buy and Hold: According to some theories, prices are indepen- For the designed case study, the configuration described in Ta-
dent to each other, meaning that we cannot use past data to ble 11 was applied, particularly, all stocks from the DJI were con-
forecast market development, so the best strategy we can sidered for performance analysis and for picking up the most
employ is Buy and Hold on which we maintain a specific set promising for the portfolio composition, the maximum portfolio
of assets regardless of market fluctuations. In this case the mar- size is parameterized and was here set to 10, additionally, both
ket index was considered as reference for the B&H strategy. long and short selling was allowed including transaction costs
Random: The random strategy implemented has a purely ran- and, finally, the process was executed for 100 times in order to al-
dom behavior; each new week the portfolio is updated by clos- low a proper.
Table 13 References
Case study – classification parameters.
Parameter Random GA Best GA Aranha, C., & Hitoshi, I. (2008). A Tree-based GA representation for the portfolio
optimization problem. In Paper presented at the Proceedings of the 10th annual
ROI (%) [21.97, 14.77] [16.68, 25.29] 62.95 conference on Genetic and evolutionary computation (GECCO), Atlanta, USA.
Sharpe Ratio 0.93 0.21 0.67 Aranha, C., & Iba, H. (2007). Modelling cost into a genetic algorithm-based portfolio
Sortino Ratio 1.25 0.40 21.03 optimization system by seeding and objective sharing. In Paper presented at the
Positions [1371, 1389] [151, 159] 156 IEEE Congress on Evolutionary Computation (CEC), 11.
Profitable Positions (%) [46.83, 47.55] [80.24, 81.50] 88.46 Aranha, C., & Iba, H. (2009). Using memetic algorithms to improve portfolio
Non Profitable Positions [52.45, 53.17] [18.50, 19.76] 11.54 performance in static and dynamic trading scenarios. In Paper presented at the
(%) Proceedings of the 11th annual conference on Genetic and evolutionary
computation (GECCO), Montreal, Canada.
Avg. Profit Per Position (%) [0.16, 0.07] [1.93, 2.53] 4.00
Arnone, S., Loraschi, A., & Tettamanzi, A. (1993). A genetic approach to portfolio
Max. Profit (%) [63.04, 78.21] [104.69, 136.57] 59.66
selection. Neural Networks World III, 6, 597–604.
Min. Profit (%) [42.96, 39.03] [36.46, 34.94] 30.28 Black, F., & Litterman, R. (1992). Global portfolio optimization. Financial Analysts
Journal, 28–43.
Bodas-Sagi, D., Fernández, P., Hidalgo, J. I., Soltero, F., & Risco-Martín, J. (2009).
Multiobjective optimization of technical market indicators. In Paper presented
In respect to the evolutionary strategy, the GA kernel was set at the Proceedings of the 11th annual conference on Genetic and evolutionary
with the parameters described in Table 12. Here, Sliding Window computation (GECCO), Montreal, Canada.
Branke, J., Scheckenbach, B., Stein, M., Deb, K., & Schmeck, H. (2009). Portfolio
refers to the training/testing period combination employed during optimization with an envelope-based multi-objective evolutionary algorithm.
the evaluation period. For instance, if the validation starts on Jan- European Journal of Operational Research, 199(3), 684–693.
uary 2003, then the previous six months are used to train the algo- Chang, T. J., Meade, N., Beasley, J. E., & Sharaiha, Y. M. (2007). Heuristics for
cardinality constrained portfolio optimization. Computers and Operations
rithm. Then, the process repeats for each six months period until Research, 27, 1271–1302.
the end of the evaluation period. Coello, C. A. C. (1999). A survey of constraint handling techniques use with
evolutionary algorithms: Laboratorio Nacional de Informática Avanzada.
Coello, C. A. C., & Cortés, N. C. (2001). Use of emulations of the immune system to
4.3. Case study – performance analysis
handle constraints in evolutionary algorithms. Intelligent Engineering Systems
through Artificial Neural Networks, 141–146.
The graph, illustrated by Fig. 12, exhibits the return on invest- Cura, T. (2009). Particle swarm optimization approach to portfolio optimization.
ment (ROI) obtained for the considered strategies within the years Nonlinear Analysis-Real World Applications, 10(4), 2396–2406.
Dow Jones Indexes (2010). from <http://www.djaverages.com>/
of 2003 to 2009, for the B&H, the Random, the proposed approach Ehrgott, M., Klamroth, M., & Schwehm, C. (2004). An MCDM approach to portfolio
(GA) and the Best GA iteration. The GA and particularly the Best GA optimization. European Journal of Operational Research, 155, 752–770.
clearly outperform the B&H and Random strategies. This, together Férnandez-Blanco, P., Bodas-Sagi, D., & Hidalgo, J. I. (2008). Technical market
indicators optimization using evolutionary algorithms. In Paper presented at
with the histogram of Fig. 13, were the results from the 100 runs the Proceedings of the 10th annual conference on Genetic and evolutionary
are outlined, shows, first, that applying a Random strategy for port- computation (GECCO), Atlanta, USA.
folio selection is clearly worse than any of the other approaches in Hassan, G., & Clack, C. (2009). Robustness of multiple objective GP stock-picking in
unstable financial markets. In Paper presented at the proceedings of the 11th
a long run, moreover, the distribution of the results from proposed annual conference on genetic and evolutionary computation (GECCO), Montreal,
strategy (GA) show that a large majority of the 100 runs lie above Canada.
the B&H giving a high confidence level for the proposed strategy. Lo, A. W., & MacKinlay, A. C. (2001). A non-random walk down wall street. Princeton
University Press.
A detailed statistical analysis on the performance of each strat- Maginn, J. L., Tuttle, D. L., McLeavey, D. W., & Pinto, J. E. (2007). Managing
egy is presented on Table 13. The intervals here presented corre- investment portfolios: A Dynamic Process: Wiley.
spond to a confidence degree of 95% determined by 100 runs. Malkiel, B. (1973). A random walk down wall street. W. W. Norton & Company.
Markowitz, H. M. (1972). Portfolio selection. The Journal of Finance, 7, 77–91.
The ROI gives a return interval for the proposed approach, referred
Murphy, J. J. (1999). Technical analysis of the financial markets: A comprehensive
as GA, which clearly is above the competing strategies outlining guide to trading methods and applications: Prentice Hall Press.
their superiority. Moreover, the number of positions with positive Ni, J. R., & Zhang, C. Q. (2005). An efficient implementation of the backtesting of
return exceeds 80%, for the GA, confirming again the high confi- trading strategies. Parallel and Distributed Processing and Applications, 3758,
126–131.
dence level of the proposed approach. Park, C. H., & Irwin, S. H. (2007). What do we know about the profitability of
technical analysis? Journal of Economic Surveys, 21(4), 786–826.
Schaerf, A. (2002). Local search techniques for constrained portfolio selection
5. Conclusions problems. Journal Computational Economics, 20, 177–190.
Streichert, F., Ulmer, H., & Zell, A. (2003). Evolutionary algorithms and the
This work proposes capable new approach to automatically cardinality constrained portfolio selection problem. In Operations Research
Proceedings, pp. 3–5.
manage a portfolio by using a GA conjugated with technical anal-
Wagman, L. (2003). Stock portfolio evaluation: An application of genetic-
ysis rules. As observed under the previous sections, the system programming-based technical analysis. Genetic Algorithms and Genetic
shows a good adaptive degree to different market trends achieving Programming at Stanford, 213–220.
Yahoo! Inc. (2010). from <http://www.finance.yahoo.com/>.
outstanding return rates. Although, several management rules
Yan, W., Sewell, M., & Clack, C. (2008). Learning to Optimize Profits Beats Predicting
were defined to increase the system performance, evolutionary Returns – Comparing Techniques for Financial Portfolio Optimization. In Paper
computation plays a fundamental role to provide a correct balance presented at the proceedings of the 10th annual conference on genetic and
between several types of technical indicators in order to pick the evolutionary computation (GECCO), Atlanta, USA.