Professional Documents
Culture Documents
Tucknik Thesis
Tucknik Thesis
net/publication/271642533
CITATIONS READS
0 369
1 author:
Petr Tucnik
University of Hradec Králové
58 PUBLICATIONS 112 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Petr Tucnik on 01 February 2015.
Introduction
1. Automated trading
Automated trading systems (ATS), in principle, does not have to maintain high level of
autonomy in order to fall into description of an ATS. In practice, it is a decision of
trader whether he/she wants to use the system independently or not. However, the
importance of monitoring system`s performance is more important with increasing
independency. This is shown at the Fig. 1.
Figure 1. Impact of selected autonomy level on trader`s workload. Attribute rises in indicated direction.
There are two extremes (considering autonomy) when defining control method of
an ATS. Most probably, depending on trader`s preference, ATS will belong to one of
them. First extreme is use of an ATS as a decision support (DS) tool. The purpose of
DS is to highlight potentially profitable business opportunities and consequently ease
trader`s workload. In some cases, a DSS may even perform trades (placing business
orders), but always after authorization by trader. Therefore, it is a trader who maintains
full control. The other extreme is full autonomy. A fully autonomous ATS is placing
trading orders without trader`s manual authorization and acts independently. Obvious
risk here is a risk of financial loss, but this can be significantly reduced by suitable
application of risk/money management rules. In fact, fully autonomous ATS may be
more profitable than manual trading. There are several advantages of autonomous ATS
which are often mentioned in this context [8]:
• Emotional trading elimination
• Greater discipline in following strategy rules and more consistent behavior
• Participation is virtually guaranteed in the direction of every important trend
• Losses are minimized (rules of money/risk management are precisely
followed)
And main disadvantages are:
• Most mechanical systems are trend-following
• Trend-following systems rely on major trends in order to be profitable
• Non-trending markets are non-profitable (selection of market is important)
• Occurrence of long periods of non-trending are rendering mechanical system
useless or non-profitable
• It is difficult to mechanically recognize that market is not trending (system is
not able to turn itself off)
Several major advantages listed in the list are related to area of trading psychology. As
it is not purpose of this text to discuss such matters, detailed description of these
aspects will be omitted. But has to be emphasized that appropriate psychological
attitude is one of the most important parts of success in trading. Experts often highlight
the importance of trading psychology and it is considered to be more important than
trading system itself or selected risk management strategy.
It is important to take into consideration, that we approach our topic from the
perspective of a small speculator. Bigger subjects on the market (banks, hedge funds,
etc.) have different issues related to trading. Limited financial capabilities of small
speculator are counterbalanced by complete freedom of choice. Small speculator may
select freely any approach or strategy, using tools, risk/money management rules, etc.
according to his/her wish. From this perspective, trading realized in small scale and
with trader`s own money is extremely unrestricted.
Trading system (TS) is a set of rules defining how to place trading orders. It is an
implementation of a trading strategy which is completely depending on a trader to be
invented, for more details see [2], [4], [5] or [1]. Any approach may be valid, and as
there are significant differences between markets, approach unsuccessful on one market
may be profitable at different one.
There are several rules to be followed but generally, the above mentioned is valid.
Trader really has complete freedom in designing the system, see [6]. Worst possible
outcome is loss of money. Rules of TS design are generally intended to reduce risk of
financial loss, so it is always better to follow them. Risk and money management rules
([8], [3]) are described in more detail in another chapter, and therefore, at this moment,
the focus will be at the design procedure itself.
The freedom of choice when designing trading strategy (trading system) is
especially obvious in the case of small speculator - which is our perspective at this
moment. This is given by several circumstances:
In the preparation phase, trader faces several major decisions. Most important is the
step (1) where decision about amount of allocated funds has to be made. This is really a
starting point of the trading process, because of its critical consequences. Every
commodity is different and can be traded only with adequate funds, depending on
futures contract parameters. Market volatility plays primary role here because all risk
management measures are derived from it (e g. there is an influence on stop-loss
placement). Secondary is margin size. With introduction of e-mini markets margin
sizes decreased even for markets which are typically considered to be more expensive
(like oil, etc.). Margin is less important because it is normally repaid back after the
position is closed, see [3], [7] or [8] for more details.
The second major decision is commodity selection in the step (2). Its importance
has already been indicated in the commentary of the step (1). It is followed by volatility
and trend assessment (step (3)) and liquidity assessment (step (4)). Volatility increases
occurrence of trading opportunities because it is more likely to obtain a positive trading
signal in market with activity. Also, a presence of trend is required. Most of mechanical
(automated) trading systems use indicators to recognize trend and it is generally more
likely to trade successfully while using the trend than not. It is also generally
recommended by experts in the field to use the trend to one`s advantage. Elementary,
often quoted, rule is “trend is your friend” (original author unknown). Liquidity
assessment concludes this phase of lifecycle; it is necessary to have market where
orders will be processed without significant delay.
The market study phase focuses on familiarization with the market environment. Trader
must be able to trade manually before he/she tries to implement ATS. This is the reason
why the paper trading step (5) is included here. It is a common mistake of beginners to
expect automated trading system to make all the work. In reality, it is quite the opposite
– it is trader who does all work and ATS serves only one purpose: to ease workload.
The following step is testing of selected indicator (6). It is a common practice to
prefer some indicator(s) over others; this is matter of personal preference and “feel” for
the selected tool [14]. Each trader prefers different set of indicators and since there is
theoretically endless selection of indicators available it is nothing to be concerned
about as there is no general rule to follow in selection of indicator. On the other hand,
not every indicator is suitable for all markets. Best way for trader to avoid any
unsuitability is to familiarize himself/herself with several selected indicators working
on different principles to be sure he/she has a tool available at his/her disposal for the
selected market, whichever it may be. The step (6) is not to be taken as a backtesting
but rather familiarization with selected tools and making sure they work well in the
environment. The most suitable indicator is selected in the step (7).
The ATS development phase is focused on analysis (8) and implementation (9).
Analytic step (8) is required only in case of complicated trading system and it is
arbitrary. It is always preferable to have existing documentation (including schematics
or diagrams) in case of later use of ATS in different environment. In any case, it is
necessary to make sure there are detailed comments in the source code of the ATS
application for subsequent changes, if required. Please note that typically, a specialized
programming language is used, depending on the platform used for implementation.
E.g. Tradestation uses EasyLanguage, AmiBroker platform uses AFL (AmiBroker
Formula Language), Ninja Trader uses Ninja Script language, etc. See respective
homepages for more details on this topic.
In the Testing and optimization phase a backtesting procedure (step (10)) is used to
validate indicator settings or to find optimal one (step (11)). Backtesting uses historical
data (there are several decades of trading data available, both as a commercial or free
product, going back to approximately 60s (depending on provider)). On historical data,
TS is applied, using implemented rules, and trading strategy and results of this
application are available to the user. It is also possible to optimize its performance by
finding more appropriate setting of the indicator (this will be described in more detail
later). In the step (12), selected settings of indicator is used which is either requiring
changes in implementation (back to step (8)) or it is ready to use (step (13)).
The last phase is using created ATS for trading. Please note that markets are
developing over time, their parameters and trends are changing, etc. Therefore, it may
be necessary to backtest ATS periodically for verification of validity as well as
optimize its settings in order to prolong its use.
3. Fundamental Analysis
Figure 3. Example beginning of possibly very strong seasonal movement in area indicated by rectangle
(source www.mrci.com)
At the Fig. 3, there is a current market price compared to its historical 9 year pattern
(upper part) and for comparison, there is also 9 year pattern and 5 year pattern shown at
the bottom of the figure. The trading opportunity should be obvious from the figure
(area indicated by rectangle). It is really highly probable that in this case the price chart
will follow its historical pattern (see below). Pattern recognition techniques are very
useful, see [9] or [10], but at this moment, a comparison of both historical and actual
price chart will suffice.
Other important aspect of each market is its liquidity [3]. Markets with low liquidity
are difficult to be traded mechanically.
While trading spreads or commodities in general, liquidity is dependent on
commodity contract expiry date. Contracts which are near their expiration are traded
most intensively, see Fig. 6.
Figure 6. Wheat futures volume and open interest report. Most important are columns Volume and RTH
Volume – Open Outcry (www.cmegroup.com).
As can be seen at the Fig. 6, greatest volume of trades is in closest months. ATS should
be trading MAY or JUL contracts. Although it is possible to trade other months, it is
not recommended for ATS (such investment is too long and we are not considering
positional trading here, moreover, there is no advantage in such trade).
In order plan timing of trade exit, it is often useful to look at the historical price chart.
Example of market where the exit level is quite obvious is at the Fig. 7. Exit level is
approximately at value of -17, as it is indicated by line.
Figure 7. Price bottom is at the value of -17. Price fall can be expected to stop at this level. (www.mrci.com)
Such information may be used for placing stop-loss orders or profit targets during
trading.
The principles and results described above leads to idea of more efficient way of
trading. With development in artificial intelligence and autonomous systems, one
should be able to extend efficiency of single stand-alone trading system to more
efficient structure of several systems working together.
In this part of the chapter, the architecture of multiagent system using contract net
protocol will be introduced - on theoretical basis only. This is intended as a future work
in this field and it is a natural continuation of the nowadays trend which is slowly
enforcing use of mechanical trading. Increased demand of such solutions may be
expected in the future.
In large trading companies, it may happen that several traders share the office.
Although every single one of them uses his/her own system, based on different trading
ideas, all have overall positive results (otherwise they would not be able to keep the
job). The idea here is similar to this situation. When several systems are performing
efficiently on their own it should be possible to shift the autonomy to even higher level
– to the level of ATS working together autonomously. Of course, elementary design
rules should apply here as well: trader has to maintain confidence and trust in such
solution and, when needed, be able to shut the system off, make changes or
modifications and be able to monitor all the system`s activities when it performs its
tasks.
This idea leads to construction of modular system, allowing autonomous trading
systems work together. The inspiration is taken from the multiagent systems and their
architectures [11] – proposed system will be using contract net protocol for
communication and coordination (see below). Separated ATS solutions will be
perceived as agents in this context. This does not change our perspective, agents and
ATS have many attributes in common, see Fig. 3 for comparison.
Figure 8. Comparison of agent and ATS activity
When compared, agent and ATS show many similarities (Fig. 8). The loop between
environment scanning, decision making and actions is called sense-think-act cycle (Fig.
8, left). It is described in detail in literature; see [Russell and Norvig].There is very
similar cycle in ATS (Fig. 8, right). Because it is possible to imagine software agent
instead of traditional hardware robot then there are no significant differences in those
two concepts. From our perspective ATS may interpreted as an agent and it would pose
no problems.
Fig. 9 describes mutual communication between agents in the system. Manager agent
starts communication with notification (of available work) and seeks the best possible
candidate for the job. In this case, manager agent is trying to find the most suitable
trading system for the market intended to be used for trade. Task agents react by
sending their responses and manager agent either accept or reject their offer. Accepted
agents are informed and may begin work. This is general sequence which will be
modified for our purposes below.
Since task agents represents individual trading systems here, they will be called
“trading agents” (TRA) in the following text. Description of graphical elements used in
following figures is shown in the Tab. 1.
The Fig. 10 shows manager agent`s (MAN) activity, divided into 17 steps. This
sequence corresponds with the Fig. 4, but it is more detailed and modified to fit ATS
needs. The overall goal here is to find the most appropriate agent (trading system) for
selected market environment.
In the step (1), MAN reads market parameters. At this point, it is presumed that
user specifies set of markets intended for trade. Therefore, database DB-MP is input of
the algorithm. In order to avoid unsuitable markets – trading of such markets most
probably results in financial loss – a filter is applied in step (2). Suitability is
considered from the perspective of ATS. Not all markets are ideal for mechanical
trading. Most important attributes are liquidity and presence of trend. Price chart
without recognizable trend (i.e. chopping or “moving to side”) can be more effectively
traded manually, but ATS application is not effective here. Also, transaction costs are
to be considered here as well. Too expensive markets would bind most of trader`s
trading account. For small speculator, e-mini markets are generally more suitable
because of smaller margins and contract prices. Remaining candidates (markets) are
sorted (3) and a structure “WORKLIST” is created (4). Preference in the step (3) is
given by trader.
The first item in the list is selected (5) and all TRA agents are notified (6). TRA
agents perform backtesting to verify their profitability and results are send back to
MAN agent (7). After evaluation of results (8), TRA agents are notified about the
decision (9) and funds are allocated from the trading account to the most successful
TRA agent (10). Processed market is deleted from the WORKLIST (11). If there is
enough money on the trading account (12), sequence continues with next item in
WORKLIST (13). Otherwise, MAN agent waits for TRA agent(s) to finish trading (14)
and funds are collected (send back) to MAN agent (15). For statistical analysis
purposes and evaluation of system performance, trading records are collected from
TRA agents, which performed trading (16). Results are saved into LOG (17) for later
analysis or simply to be at the user`s disposal.
The multiagent system described in part 4.2 serves two main purposes – it helps to find
the most suitable trading system for given market and distributes funds between
individual trading systems. Such coordination structure could be very helpful in trading
organization, especially when larger number of trading systems is to be used at the
same time.
Obvious risk here is loss of control. There are mechanisms incorporated into
system designed specifically to prevent this – periodical evaluation of system`s
performance, logs, information sharing, transparency. The overall structure is logical
and contains only necessary parts. Although list of elements in Tab. 1 may seem to be
too long, most items on the list are data separated into specialized “storages”.
The function of the system was explained using intraday perspective. Whole
procedure (Fig. 10 and Fig. 11) can be easily modified for other type of trading. The
intraday trading is more transparent, because at the end of each trading day are results
at the disposal of trader.
5. Conclusion
Acknowledgements
This work and contribution were supported by the Specific Research Project
“Automated Trading Systems for Futures Trading”.
References
[1] Angell, G., Real-Time Proven Commodity Spreads – The 20 Most Consistently Profitable Low Risk
Strategies, Windsor Books, USA, 1985.
[2] Aronson, D., Evidence-Based Technical Analysis – Applying Scientific Method and Statistical Inference
to Trading Signals, John Wiley & Sons, USA, 2007.
[3] Carter, J. F., Mastering the Trade – Proven Techniques for Profiting from Intraday and Swing Trading
Setups, McGraw-Hill, USA, 2006.
[4] Dunsby, A.; Eckstein, J., Gaspar, J., Mulholland, S., Commodity Investing – Maximizing Returns
Through Fundamental Analysis, John Wiley & Sons, USA, 2008.
[5] Holihan, M. B., The Complete Guide to Investing In Commodity Trading and Futures - How to Earn
High Rates of Returns Safely, Atlantic Publishing Group, USA, 2008.
[6] Kaufman, P. J., New Trading Systems and Methods (4th Ed.), John Wiley & Sons, USA, 2005.
[7] Kirkpatrick, C. D., Dahlquist, J. R., Technical Analysis – The Complete Resource for Financial Market
Technicians, Pearson Education, New Jersey, USA, 2007.
[8] Murphy, J. J., Technical Analysis of the Financial Markets – A Comprehensive Guide to Trading
Methods and Applications, New York Institute of Finance, USA, 1999.
[9] Nison, S., Japanese Candlestick Charting Techniques (2nd Ed.), Prentice Hall Series, USA, 2001.
[10] Pesavento, L., Jouflas, L., Trade What You See – How to Profit from Pattern Recognition, John Wiley
& Sons, USA, 2007.
[11] Russell, S., Norvig, P., Artificial Intelligence – A Modern Approach (2nd Ed.), Prentice Hall – Pearson
Education, USA, 2003.
[12] Tinghino, M., Technical Analysis Tools – Creating a Profitable Trading System, Bloomberg Press,
USA, 2008.
[13] Tucnik, P., Automatic Trading System Design, in Pervasive Computing for Business: Trends and
Applications, IGI Globa, Australia, 2010, pp. 183-200.
[14] Tucnik, P., Optimization of Automated Trading System`s Interaction with Market Environment, In:
Perspectives in business informatics research (9th international conference (BIR 2010)), Springer,
Germany, pp. 55-61.