Professional Documents
Culture Documents
Abstract The possibility of obtaining financial gain by techniques such as fuzzy logic and neural networks are being
investing in the Stock Markets is a hard task since it is under widely used in an attempt to find satisfactory solutions to this
constant influence of economical, political and social factors. This problem [2].
paper aims to address the financial technical analysis of Stock
Markets, focusing on time series data instead of subjective
parameters. An algorithm based on genetic programming,
The automation of stock trade transactions is now a reality,
named GoldMiner, has been proposed to perform retrospective as it can be observed in several studies [2,4,6,7,9]. The
study in order to get predictions about the best time for trading algorithms developed for this purpose ignore the efficient
top stocks on the BOVESPA, the Brazilian stock exchange market hypothesis and, therefore, have faced difficulties in
market. nonlinear time series forecasting.
Keywords genetic programming, technical analysis, This work proposes a computer system for decision-
exchange market, decision making making in stock trading at the Brazilian exchange market,
BOVESPA. The developed algorithm, named as GoldMiner,
was built based on four main concepts: genetic programming,
I INTRODUCTION technical analysis of the stock market, scanning step, and
The stock market is seen as a possible source of income, trading systems with targets.
but its nature is complex and unstable. Predicting its future
behavior is not a simple task, since the stock market is The article was structured as follows: section II presents
constantly influenced by economical, political and social the work related to the topic. In section III, schemes of
factors. representation, operators of genetic programming and
indicators of technical analysis are. In section IV, an instance
Some economists claim that the efficient market of the problem and the testing framework is shown. Section V
hypothesis is valid [10]. This theory states that the price discusses the results in four BOVESPA top stocks: BOVA11,
variation of a stock behaves like a random walk and therefore VALE5, PETR4, and BBAS3. Finally, some conclusions are
any price forecasting technique consists on a useless effort. presented in Section VI.
Another issue to be considered is the non-linearity of price
variation of an asset on the stock exchange.
II RELATED WORK
Despite the difficulties in financial time series forecasting, In this work, the forecasting techniques employed to stock
many efforts have been destined to provide better markets will be classified in three categories: conventional
understanding about the stock markets. Unconventional
The features of the system are presented below. Figure 1 - buying decision tree
A. Technical Analysis
In GoldMiner, 12 indicators of technical analysis [5] were
used as shown in Table I. All of these indicators are explained
in reference [5].
1
Forex is an equity market that is characterized by high liquidity, a fact that
allowed Myszkowski P.B. [6] [7] to work with daily trading, also called Figure 2 - selling decision tree
Daytrade Operations.
398
The initial population of the GP has been implemented 3. The selected individuals are tested on the
using the Grow method, the crossover by point and the shrink window tests I and II.
mutation [3]. The selection is based on binary tournament.
The configuration and construction of the GP and the training 4. The individual with higher fitness and more than
parameters are shown in Table II. The GP follows the steps of 20% return in window tests I and II is chosen to be
an evolutionary algorithm, as follows: evaluated in the forecasting window.
5. If no individual meets the requirements described
1. Generate the initial population using the Grow in step 4, run the procedure again from a new initial
method. population generated in step 1.
2. Calculate the Fitness of the solutions.
3. Perform selection using binary tournament. The implementation of the verification system was
necessary because it was observed that individuals with best
4. Apply the operators (mutation and crossover) fitness in the training phase can be very ineffective in the
according to the given probabilities. forecasting window. The success rate has risen considerably
5. If he stop criterion is not met, return to step 2. with the use of the verification system, reaching gains up to
30%.
TABLE II CONFIGURATION OF GP
TABLE III DECISION MAKING FOR BUYING AND SELLING D. Trading System and Goals
Buying Decision Tree Selling Decision Tree Action The core of a system that buys and sells stocks on the
False False Stay stock exchange can be divided in two key modules: (i)
True False Buy
False True Sell decision module and (ii) trading module. The decision module
True True Stay is responsible for making decisions that, in the case of
GoldMiner, are guided by two decision trees (buying and
selling trees). The second module addresses how the
C. Verification System negotiation will be executed. It is responsible for selling,
buying or performing shutdown operations.
As stated earlier, GoldMiner differs from studies carried
out by Myszkowski P.B. [7] in four specific points: the The trading module that was built has four characteristics:
targeting system, the system of trading on the stock exchange, It makes use of rented stocks.
the system of prior check solutions and parameterization of
the GP. In Figure 3, the windows of training, checking and It leverages the capital once the value of available assets.
forecasting are presented. It buys and sells on the closing price of the market.
It uses a target profit of 10% as stop condition.
The verification system was created in order to improve
the hit rate. Its operation consists on the following steps: The rented stocks can be traded without necessarily being
owned. This type of operation is a practice in the stock market
1. Evolve the population in the training window. called short selling [5].
2. After the training, ten individuals with the best
fitness are selected.
399
Another common practice in the stock market is to validation and prediction were performed in the range of T =
leverage [5] in purchase and sale transactions. In finance, 30 on 02-24-2010 until T = 1026 on 02-28-2014.
leverage is a general term for any technique applied to
multiply the profitability through debt. The leverage also Table V presents the intervals of training, checking and
increases the operation risks. GoldMiner works leveraging the prediction windows.
stocks by once. TABLE V TRAINING WINDOW, VERIFICATION AND FORECASTING
It has been set that when GoldMiner reaches a profit of The starting date of the forecast window was added by two
10%, then the operations are closed. This profit is compatible days each test, and it was repeated 30 times. This variation in
with the Brazilian economy. The profitability of the Brazilian the forecast window aimed to test the consistency and
government bonds ranged between 8% and 10% annually, robustness of the results achieved by GoldMiner.
considering the forecast from 2013 to early 2014 [11]. The
system aims to return at least 10% of profit on a maximum of V-RESULTS
one hundred and ninety days. In Figure 4 and Table VI it can be observed the operation
of the trade system. Decisions to buy, sell and close for
BOVA112 stock are presented.
IV. INSTANCES AND TESTS
Myszkowski P. B. [7] proposed a software that operates
primarily with daytrade operations [5] in a strong liquidity
market. This fact enables that predictions and negotiations are
carried out at intervals of 5, 10 and 15 minutes. However, on
the BOVESPA, even for top stocks (so-called Blue Chips), any
forecasting system to daytrade operations should consider book
offerings. Indications to buy or to sell a stock at a given
moment can be executed only if there are interested buyers and
sellers available. Therefore, although BOVESPA liquidity is
not critical as in other markets (i.e. Forex), there are two
moments on the day in which buying and selling indications of
blue chips can be executed with high probability: one hour
after the market opening and at the final 30 minutes [8]. This
aspect justified the choice for day candles in GoldMiner, in
which the transactions are performed at the close of market.
Up to now, the GP was tested on BOVESPA with four
stocks, namely BOVA11 VALE5, PETR4 and BBSA3. These
stocks have been selected because they have representation in
BOVESPA index and they present liquidity for being bought
and sold in day candles. In Table IV, a brief description of each
of them is shown. Figure 4 BOVA11, example of the trading system
400
BOVA11 30 27 90% 53,83 days
2 R$ 54,86 Sold Bought R$ 1.040,50 R$ 0,00 PETR4 30 28 93,33% 55,76 days
VALE5 30 27 90% 33,56 days
BBAS3 30 29 96,66% 80,93 days
3 R$ 54,15 Bought Sold R$ 1.026,60 R$ 2.053,00
Boxplot graphs with details about these results can be seen
in Figures 5 and 6. They present the financial returns of the
4 R$ 51,95 Sold Bought R$ 1.067,57 R$ 0,00
stocks and the time required to obtain these returns.
In Figure 5, the variation of the intervals is minimal since
5 R$ 53,69 Bought Stop R$ 1.103,32 R$ 1.130,32
when the profitability reaches 10%, the operations are
terminated. Since the buying and selling operations are
It is important to emphasize that operating costs, rental conducted at market closing, most part of the profits are
costs and fractioning batch were not considered in this work. slightly above 10%. The outliers in Figure 5 also indicate that
It is expected to include such features in future versions of GoldMiner did not reach the set target. In the case of VALE5,
GoldMiner. In general, the rental price of a stock can vary it has been observed loss in some runs.
from 1% to 5% of its value. In the specific case of BOVA11,
the rent value for the period of the operations was 2.5% per
year [8].
401
investments is to buy assets with positive history and keep VALE5 -1,88 9,21
these stocks for an indefinite period of time. BBAS3 5,12 10,77
Table VIII presents some of the results obtained with
BOVA11 stocks in the Buy and Hold strategy compared to the
results obtained with GoldMiner. The observed results indicate that the proposed algorithm is
able to reach good profit in several situations, being this
strategy considerably better than the Buy and Hold strategy. In
TABLE VIII - BUY AND HOLD VERSUS GOLDMINER TO BOVA11 addition, it was possible to obtain such profit in very short time
on the considered stocks.
Days Buy and GoldMiner Window Forecasting
Hold training window
VI - CONCLUSION
31 -6.45 10.00 530-777 778-1020
In this work, GoldMiner, a decision-making and trading
29 -6.98 10.00 530-777 780-1020 algorithms for the stock market is presented. This system uses
62 -11.93 11.53 530-777 782-1020 genetic programming combined with indicators of financial
technical analysis. The application identifies the time of
62 -17.18 11.33 530-777 784-1020
purchasing and selling stocks, considering the liquidity of the
60 -14.02 11.33 530-777 786-1020 market when it is ner to close.
58 -11.79 11.33 530-777 788-1020 This software was tested on BOVESPA with four top
stocks in different time windows. Initial results are promising;
the target time and profity were reached in more than 90% of
56 -11.98 11.33 530-777 790-1020
the runs.
The combination of genetic programming with technical
54 -11.42 11.33 530-777 792-1020 analysis has previously been treated in the literature, but the
inclusion of the two windows of verification and the trading
52 -9.43 11.33 530-777 794-1020 system features a key distinguishing point for reaching the
results of this work.
48 -11.33 11.47 530-777 798-1020 The authors would like to thank the Brazilian agencies
CAPES, CNPq and FAPEMIG by the financial support.
46 -10.58 11.47 530-777 800-1020
REFERENCES
44 -9.80 11.47 530-777 802-1020 [1] G. S. Atsalakis and K. P. Valavanis Surveying stock market forecasting
techniques - Part I: Conventional methods. In Zopounidis C.,
Computation Optimization in Economics and Finance Research
42 -11.53 11.47 530-777 804-1020 Compendium, p.p. 49-104, Nova Science Publishers, Inc, New York
[2] G. S. Atsalakis and K. P. Valavanis Surveying stock market forecasting
In which: techniques - Part II: Soft computing methods Expert Systems with
- Days the number of days that show the time required for the Applications Vol. 36 35932-5941 April 2009
return achieved by GoldMiner. [3] Koza J.R., "Genetic Programming: On the programming of computer by
means of natural selection", MIT Press,1992
- Buy and Hold - Return obtained after using the Buy and Hold
Strategy [4] Neely C., Weller P., Dittmar R., "Is Technical Analysis in the foreign
exchange market profitable? A Genetic Programming Approach, Jour. of
- GoldMiner - Represents the appreciation/depreciation of the stock finan. and Quantitative Analysis 32(4), pp. 405-426,1997
at the time GoldMiner was used.
[5] Murphy J. "Technical analysis of the financial markets", 1999.
- Window Training - Training Period of GoldMiner. [6] Myszkowski P.B. , Rachwalski L.., Trading rule discovery in warsaw
- Forecasting window - Period in which GoldMiner acts, buying and stock exchange using coevolutionary algorith., ms, 4th inter. symp.
selling stocks. advances in AI and App., Mragwo(poland), pp81-88,2009.
[7] Myszkowski P. B. and Bicz A. Evolutionary algorithm in Forex trade
Table IX shows the average profitability of all Goldminer strategy, Proceedings of the 2010 International Multiconference on 81-
executions compared to the average profitability of the Buy 88 18-20 Oct. 2010
and Hold strategy. [8] http://www.bmfbovespa.com.br
[9] D. Mallick, V. C. Lee and O. Yew Soon. An empirical study of Genetic
Programming generated trading rules in computerized stock trading
TABLE IX BUY AND HOLD X GOLDMINER AVERAGE PROFITABILITY service system, 2008 International Conference on 30 2008-July 2 2008
Stock Buy and Hold GoldMiner [10] Fama, Eugene F. Ecient capital markets: a review of theory and
empirical work. Journal of Finance, 25:383-417, 1970.
BOVA11 -9,69 10,15 [11] http://www.bcb.gov.br
PETR4 -9,37 10,94
402