Upload
kitsukete
View
213
Download
0
Embed Size (px)
Citation preview
7/27/2019 A stock trading algoritm.pdf
1/6
Informatica Economic vol. 15, no. 1/2011 183
A Stock Trading Algorithm Model Proposal, based on Technical Indicators
Signals
Darie MOLDOVAN, Mircea MOCA, tefan NICHI
Business Information Systems Dept.
Babe-Bolyai University of Cluj-Napoca
{Darie.Moldovan, Mircea.Moca, Stefan.Nitchi}@econ.ubbcluj.ro
The algorithmic stock trading has developed exponentially in the past years, while the
automatism of the technical analysis was the main research are for implementing the
algorithms. This paper proposes a model for a trading algorithm that combines the signals
from different technical indicators in order to provide more accurate trading signals.
Keywords: Decision Support System, Trading Algorithm, Technical Analysis
IntroductionThe use of technical analysis indicators in
decision making for stock investments stays
a controversial subject, being appreciated by
some investors, but rejected by others [4].
While professionals and researchers from the
academic world developed new methods and
indicators, live or simulated tests are needed
to validate them [5].
The price prediction is a very complex issue,
and selecting the right technical indicators
for the analysis of a particular stock is one ofthe first preoccupations of the investors that
use the technical analysis. One difficulty is
the tuning of the parameters of these
indicators in a way that makes their signals
correct in a percentage as high as possible
[1]. While the behavior of the stocks is
different from one to another and changes
during time, the choice of parameters values
becomes a difficult task without the help of
an advanced computational method.
The data mining methods are considered tobe a smart choice for selecting the right
technical indicators, allowing tests on very
large datasets (an essential condition,
regarding the large volume of financial data
available) and many combinations of
parameters values, combining daily, weekly
or monthly prices for tests [2] [5].
Our objective is to propose a methodologythat combines different technical indicators,
based on tests conducted over data sets
gathered from the international or local stockmarkets, and obtaining buy or sell signals
with an improved accuracy, compared to theresults obtained using the use of a singular
indicator, comparing the results with other
research conducted.
The reminder of the paper is structured as
follows. We describe the general conditions
of trading algorithms development in section
2. In section 3 we describe our proposed
methodology for designing a trading
algorithm based on signals from three
different technical analysis indicators.
Section 4 is for conclusions and furtherdevelopments discussion.
2 Related workMost of the studies regarding the trading
algorithms are conducted either as the design
of an agent that works in a simulated
environment, proving their efficiency on the
test data or based on other studies, trying to
prove a superior approach of the problem
described.
In the past years algorithmic trading hasbecome a strong preoccupation for all the
major investors of the financial market,starting 2004 the American markets being
dominated by this kind of trading [6]. Thefirst reason for this trend is the certainty that
the algorithm will follow with perfectconsistency strict rules. Human traders
usually follow trading rules, but become
uncertain at some point that something that
worked in the past will work this time too,
and will make some changes, causing an
important damage to the trading strategy.
1
7/27/2019 A stock trading algoritm.pdf
2/6
184 Informatica Economic vol. 15, no. 1/2011
A condition for the successful
implementation of a trading algorithm is that
all the processes involved to be automated.
From the gathering of the market data to
sending the orders to the market must bedone automatically, any delay causing a loss
of accuracy. The success of an algorithm,
besides the trading strategy, depends on the
infrastructure and the programming language
used. The reaction speed of the algorithm to
the incoming market data, the processing and
the response are all key factors for the
success or failure. The faster the algorithms
react to live data, the better the strategy
proposed will be applied.
The scope of the algorithm is to take profitfrom the price changes of the stock traded,
considering precise rules, considering themarket data (price and/or volume traded) and
offering buy or sell signals.The main types of trading algorithms are
considering momentum, relative-value ormarket microstructure. The first category
tries to determine trends, based on pricemovements, considering different statistical
indicators, the most common being theaverage. They are considered to perform
better on markets that have a persistent trendin time. Our approach is for this type of
algorithms, as will be discussed later.Another type of algorithms is the one that
compares the evolution of one or more
financial instruments and, based on this, buys
the ones considered undervalued and sells the
overvalued ones.
The algorithms based on the microstructure
of the market will consider the order bookinformation, processing information that
otherwise is difficult to keep and observe by
a human trader and develop a time-effective
strategy.
According to Russell [8] the performance of
a trading algorithm can be tested by three
different approaches: the first is when one
will use a given probability distribution for
the stock prices the Bayesian method; the
competitive analysis assumes the worst case
possible and considers uncertainty for theprices; the other approach is to test the
algorithms on a simulated environment,
using historic data collected.
The signal indicator considered in our model
proposal is a combination of three
momentum indicators used by the technicalanalysis and the benchmark will be if a signal
aggregation will lead to better results than the
signals gathered individually from the
indicators.
The three indicators are MACD(Moving
Average Convergence-Divergence),
ROC(Price Rate of Change) and STS
(Stochastic Oscillator).
MACD is a widely used indicators andtracks the changes in strength, direction,
momentum and direction of a trend. It iscalculated considering the Exponential
Moving Average(EMA) for two different
periods and compare them.
The formula for calculating an EMA at a
certain point is the following:
where is a constant smoothing factor
expressed like a percent or as the number
of periods .
Generally,
EMA=
The weighting factor in each data point(p) is decreasing exponentially, so the
older the data point, the less influence willhave in the result.
Next, the MACD formula is the
following:MACD = , where a < b.
The trade signals are given when the
EMA for the shorter period increases at ahigher value than the longer EMA
( ) - a buy signal - or the
shorter EMA becomes smaller than the
longer EMA .
The Price Rate of Change (ROC) indicatoris an oscillator that calculates themovement of the price between the
7/27/2019 A stock trading algoritm.pdf
3/6
Informatica Economic vol. 15, no. 1/2011 185
current time price and the one of n periods
of time before.
The calculation formula is the following:
or the relative value:
Where t is the current time and n is the
number of periods of time in the back.
The ROC signals when a certain stock is
overbought or oversold, the tradingsignals occurring when a divergence
appear against the current price evolution.
The Stochastic Oscillator measures themomentum of the market by considering
the trading range from a certain period oftime.
For the calculation we use the followingformulas:
where C represents the closing price of the
stock, L the lowest price for the period,
while is the maximum price.
%D = 3 period MA(%K),
Where MA(%K) is the moving average of
%K.
3 Proposed methodologyThe algorithm gets in touch with two
independent entities and an efficient
communication between them must be
assured. First the database from which the
data for analysis is gathered in real time. This
is a one way communication, from the
database to the system. An important issue is
the consistency of the data, missing orunformatted data is not acceptable, the
technical indicators being very sensitive.
The other entity is the market(e.g. Stock
Exchange). A mutual communication is
needed in this case. The system sends trading
orders to the market and the market sends
responses whether they were executed or not.
A very stable and fast connection is needed
between the two, the execution speed being a
very important factor for the success of a
trading algorithm, sometimes the precisionmust be of milliseconds [7].
Inside the system, the trading algorithm is thecore. All other processes send their signals to
the algorithm, which reacts depending on thecalculations made, deciding whether to send
orders to the market, close the open positionsor not to react at all, just wait for the data to
change so new information becomesavailable.
The system will perform additional tasks, inaddition to the trading signal aggregation.
These tasks are the open positionsmanagement and risk management.
Figure 1 shows the integration of thealgorithm in the whole system.
Market DataStock
Exchange
Trading Algorithm
Signal 1 computation Signal 2 computation Signal 3 computation
Trading ordersExecution
confirmations
Fig. 1. Integration
The functionality of the system depends notonly on the optimal design, but also on the
programming language used. Russell andYoon[8] consider the .Net framework the
7/27/2019 A stock trading algoritm.pdf
4/6
186 Informatica Economic vol. 15, no. 1/2011
most appropriate due to its superior
flexibility, scalability compatibility and
interoperability.
Before entering a trading order, the system
must do some validations regarding themanagement of the positions owned and the
risk management.
B/S Signal
No
Open positions
Yes
No
Enter order
YesCheck
exposure limit
Not exceeded
Exceded
Indicators Computation
Fig. 2. Functionality
A very often verification of the trading signal
must be performed (this interval can be
settled depending on the trading strategy,
whether it will be a high frequency trading or
not). If a signal was issued the status of thecurrent open positions must be checked. An
exposure limit that was reached will not
allow an order to get in the market.
Figure 2 shows the flow of the order
validation before entering the market. The
flow is a continuous one, in any of the
situations occurred; the end of the
verification process will mean the beginning
of a new flow, with different parameters
obtained from the indicators calculation
module.The risk management process must also take
place in real time, alongside with theindicators calculation and order management.
The value of the open positions and cashavailable must be carefully correlated with
the terms settled when the algorithm starts,the tuning of parameters like order value,
profit and loss limits depending on testsconducted in a simulated environment but
also considering the liquidity of the market,and different risk levels accepted.
Profit/Loss Calculations
ProfitLoss Limit
ExceededNo
Enter closeposition order
Yes
No
Profit Limit
ExceededYes
Yes
No
Fig.3. Risk management
Figure 3 shows the risk management process.Like all other processes involved in the
system, it is a continuous one, the end of acycle represents the beginning of a new one,
7/27/2019 A stock trading algoritm.pdf
5/6
Informatica Economic vol. 15, no. 1/2011 187
until the algorithm stops. The risk
management process is responsible not only
for the loss limitation but also for cashing the
profit. It has the priority 0 in the system,
having the power to stop the entry of a neworder in the market even if the order would
have been valid in other circumstances.
One important issue is the one of tuning the
parameters of the technical indicators. Even
if in practice there are some standard values
for them, the performance of the algorithm
can be much affected by a non-optimum
parameter value chosen. The main factors
that lead to parameters changing are the trend
(when the trend is ascending the indicators
having some particular parameters willperform considerably better than having the
same parameters on a descending trend) andthe stock behavior (depending on volatility,
the parameters must be adjusted).One smart solution to overcome the issue of
choosing among multiple combinations ofparameters values in order to find the
optimum for the data tested is the use of aGenetic Algorithm[9,10]. A greedy algorithm
that would test all the possible combinationwould be very time consuming, even it
would find the best possible solution. TheGenetic Algorithm will probably not find the
best combination, but one very close to it,acceptable considering the need of time
efficiency.
4 Conclusion and future developments
perspectivesThe combination of the three indicators in
getting trading signals was tested only byhuman traders, and the effectiveness of the
strategies needs to be proven on a simulatedenvironment in order to validate the proposed
model.The integration with a Genetic Algorithm is a
highly desirable solution in order to tune up
the parameters of the indicators in a quick
and reliable way, but also can be used in the
discovery of new trading rules.
A combination between automatically
discovered trading rules and othersdiscovered by experts observations could be
a performing way of setting up the automated
trading system.
Considering that every individual has
different risk averseness the risk-return
balance must be controlled, which may leadin a development of an evolutionary trading
system.
A limitation of the state of the art knowledge
about developments in this field is a fact that
could be an obstacle in the study, in most
cases the developers of the algorithms do not
make public the results and the methodology
used.
Acknowledgments
This work was supported by ANCS-CNMP,project number PNII 91049/2007.
References
[1] D. J. Bodas-Sagi, P. Fernndez, J. I.Hidalgo, F.J. Soltero and J.L. Risco-
Martn, Multiobjective optimization oftechnical market indicators. In
Proceedings of the 11th Annual
Conference Companion on Genetic and
Evolutionary Computation Conference:
Late Breaking Papers. GECCO '09.
ACM, New York, pp. 1994-2004.[2] M. Tanaka-Yamawaki, S. Tokuoka, K.
Awaji. Short-Term Price Prediction andthe Selection of Indicators. Progress of
Theoretical Physics. Japan, 2009, pp.17-
25.
[3] M. Tanaka-Yamawaki, S. Tokuoka.
Adaptive Use of Technical Indicators
for Predicting the Intra-Day Price
Movements.Lecture Notes in ComputerScience, Springer, 2009. pp.597-603.
[4] R.D. Edwards, J. Magee, W.H.C.
Bassetti. Technical Analysis of Stock
Trends, 9th Edition (Hardcover).
American Management Association,
2007.
[5] G. C. Silaghi, V. Robu. An agent
strategy for automated stock market
trading combining price and order book
information.In 2005 ICSC Congress on
Computational Intelligence Methods and
7/27/2019 A stock trading algoritm.pdf
6/6
188 Informatica Economic vol. 15, no. 1/2011
Applications. IEEE Computer Society,
2005.
[6] K. KIM, Electronic and Algorithmic
Trading Technology. Burlington, MA.
Elsevier, 2007.[7] A. Chaboud, B. Chiquoine, E.
Hjalmarsson, and C. Vega. Rise of the
Machines: Algorithmic Trading in the
Foreign Exchange Market. Federal
Reserve Board - International Finance
Discussion Papers. 2009-980.
[8] S. Russell, V. Yoon. Heterogeneous
Agent Development: A Multi-Agent
System for Testing Stock Trading
Algorithms. AMCIS 2005 Proceedings,
2005.
[9] L. Lin, L. Cao. Mining in-depth patterns
in stock market. International Journal
of Intelligent Systems Technologies andApplications. Vol. 4, 2008.
[10] H. Subramanian, S. Ramamoorthy, P.
Stone, and B. Kuipers. Designing Safe,
Profitable Automated Stock Trading
Agents Using Evolutionary Algorithms.
In Proceedings of the Genetic and
Evolutionary Computation Conference,
July 2006.
Darie MOLDOVAN is a PhD Student at the Faculty of Economics and
Business Administration, Business Information Systems department at
Babe-Bolyai University of Cluj-Napoca. His doctoral orientation is towards
studying the application of Data Mining in Finance. He is interested in theBusiness Intelligence field, trading algorithms and automated systems for
trading.
Mircea MOCA is a Teaching Assistant and PhD Student at the Faculty ofEconomics and Business Administration, Business Information Systems
department at Babes-Bolyai University of Cluj-Napoca. So far he worked ondeveloping distributed computing systems using structured and unstructured
P2P architectures. His research interests are volunteer computing systems andbuilding MapReduce applications for Desktop Grids.
tefan Ioan NICHI is a Professor, PhD, at the Faculty of Economics and
Business Administration, Business Information Systems department at
Babes-Bolyai University of Cluj-Napoca. He has very strong knowledge in
collaborative systems and databases. His research interests are collaborative
systems for business intelligence and distributed decision support systems.
http://www.ece.utexas.edu/~ramamoor/http://www.cs.utexas.edu/~pstonehttp://www.cs.utexas.edu/~pstonehttp://www.cs.utexas.edu/~pstonehttp://www.cs.utexas.edu/~pstonehttp://www.ece.utexas.edu/~ramamoor/