You are on page 1of 16

Quantitative Finance

ISSN: 1469-7688 (Print) 1469-7696 (Online) Journal homepage: https://www.tandfonline.com/loi/rquf20

Model calibration and automated trading agent


for Euro futures

Germán Creamer

To cite this article: Germán Creamer (2012) Model calibration and automated trading agent for
Euro futures, Quantitative Finance, 12:4, 531-545, DOI: 10.1080/14697688.2012.664921

To link to this article: https://doi.org/10.1080/14697688.2012.664921

Published online: 22 Mar 2012.

Submit your article to this journal

Article views: 464

Citing articles: 13 View citing articles

Full Terms & Conditions of access and use can be found at


https://www.tandfonline.com/action/journalInformation?journalCode=rquf20
Quantitative Finance, Vol. 12, No. 4, April 2012, 531–545

Model calibration and automated trading agent for


Euro futures
GERMÁN CREAMER*
Stevens Institute of Technology, Castle Point on Hudson, Hoboken, NJ, 07302, USA

(Received 14 May 2011; in final form 10 December 2011)

We explored the application of a machine learning method, Logitboost, to automatically


calibrate a trading model using different versions of the same technical analysis indicators.
This approach takes advantage of boosting’s feature selection capability to select an optimal
combination of technical indicators and design a new set of trading rules. We tested this
approach with high-frequency data of the Dow Jones EURO STOXX 50 Index Futures
(FESX) and the DAX Futures (FDAX) for March 2009. Our method was implemented with
different learning algorithms and outperformed a combination of the same group of technical
analysis indicators using the parameters typically recommended by practitioners.
We incorporated this method of model calibration in a trading agent that relies on a layered
structure consisting of the machine learning algorithm described above, an online learning
utility, a trading strategy, and a risk management overlay. The online learning layer combines
the output of several experts and suggests a short or long position. If the expected position is
positive (negative), the trading agent sends a buy (sell) limit order at prices slightly lower
(higher) than the bid price at the top of the buy (sell) order book less (plus) transaction costs.
If the order is not 100% filled within a fixed period (i.e. 1 minute) of being issued, the existent
limit orders are cancelled, and limit orders are reissued according to the new experts’ forecast.
As part of its risk management capability, the trading agent eliminates any weak trading
signal. The trading agent algorithm generated positive returns for the two major European
index futures (FESX and FDAX) and outperformed a buy-and-hold strategy.

Keywords: Automated trading; Machine learning; Algorithmic trading; Agent based


economics; Trading agents; Boosting

1. Introduction data instead of using daily data. Hence, there are new
challenges in the application of learning algorithms to
Most of the research applying agent-based modeling and forecast futures using high-frequency data.
machine learning methods to finance have been in the Among the most important learning algorithms used to
equity (Allen and Karjalainen 1999, Lo et al. 2000, forecast futures are the following.
Towers and Burgess 2000, Moody and Saffell 2001) and . Neural network (connectionist approach): This
foreign exchange markets (Arifovic 1996, LeBaron 1998, has been the most commonly studied approach.
Dempster et al. 2001, Bates et al. 2003, Dempster and Most systems generate trading rules using
Leemans 2006) using daily prices. There is very limited neural networks where their main inputs are
research in the area of high-frequency futures trading, but technical analysis indicators.y This approach
equity, foreign exchange and index futures trading have a has been applied to forecast and trade S&P 500
similar forecasting problem: anticipating price trend. index futures (Trippi and DeSieno 1992,
Additionally, there is a potential increase of time series Choi et al. 1995), the Warsaw stock price
variance when the analysis is done using high-frequency index 20 (WIG20) futures (Witkowska and

*Email: gcreamer@stevens.edu
yTechnical analysis or technical trading strategies try to exploit statistically measurable short-term market opportunities, such as
trend spotting and momentum, in individual industrial sectors (e.g. financial, pharmaceutical, etc.).
Quantitative Finance
ISSN 1469–7688 print/ISSN 1469–7696 online ß 2012 Taylor & Francis
http://www.tandfonline.com
http://dx.doi.org/10.1080/14697688.2012.664921
532 G. Creamer

Marcinkiewicz 2005), and Korea stock index 2. Methods


200 (KOSPI 200) futures (Kim 2006). Hamid
and Iqbal (2004) forecast the volatility of S&P 2.1. Boosting
500 index futures using 16 futures indexes and
Adaboost is a general discriminative learning algorithm
three spot prices. Tsaih et al. (1998) integrate a
invented by Freund and Schapire (1997).
rule-based system and neural network to fore-
The basic idea of Adaboost is to repeatedly apply a
cast the daily trend of S&P 500 index futures.
simple learning algorithm, called the weak or base
Duke and Long (1993) use price and economic
learner,y to different weightings of the same training set.
indicators as input to forecast daily German
In its simplest form, Adaboost is intended for binary
government bond futures prices. Kim (2004)
prediction problems where the training set consists of
uses a method of feature transformation based
pairs (x1, y1), (x2, y2), . . . , (xm, ym), where xi corresponds
on domain knowledge to discretize the data and
to the features of an example, and yi 2 {  1, þ1} is the
forecast the KOSPI 200. Even though these
binary label to be predicted. A weighting of the training
studies indicate that they outperform their
examples is an assignment of a non-negative real value wi
benchmarks, the main problem with the
to each example (xi, yi).
neural network approach is that it is very
On iteration t of the boosting process, the weak learner
difficult to interpret the trading rules generated,
is applied to the training set with a set of weights
especially in the case of complex networks with
wt1 , . . . , wtm and produces a prediction rule ht that maps
many nodes and hidden layers.
x to {0, 1}.z The requirement on the weak learner is for
. Genetic algorithm (emergent approach): The
ht(x) to have a small but significant correlation with the
genetic algorithm (Holland 1975) or genetic
example labels y when measured using the current
programming (Koza 1992) approach is used to
weighting of the examples. After the rule ht is generated,
generate evolving trading rules. These rules
the example weights are changed so that the weak
are represented as binary trees where the leaves
predictions ht(x) and the labels y are decorrelated. The
are technical indicators and the non-leaves are
weak learner is then called with the new weights over the
Boolean functions. Together they represent
training examples, and the process repeats. Finally, all of
simple decision functions. Following this per-
the weak prediction rules are combined into a single
spective, Shin et al. (1998) predict the KOSPI
strong rule using a weighted majority vote. One can prove
using nine technical indicators. The advantage
that if the rules generated in the iterations are all slightly
of this approach is that the rules are
correlated with the label, then the strong rule will have
interpretable.
a very high correlation with the label—in other words,
. Support vector machine: Tay and Cao (2001)
it will predict the label very accurately.
show a support vector machine application that
The whole process can be seen as a variational method
gives more weight to more recent values, and
in which an approximation F (x) is repeatedly changed by
improves forecasts of the S&P 500 index, and
adding to it small corrections given by the weak predic-
US and German government bond futures
tion functions. In figure 1, we describe Adaboost in these
using moving averages and lagged prices.
terms. We shall refer to F (x) as the prediction score in the
. Reinforcement learning: Moriyama et al. (2008)
rest of the document. The strong prediction rule learned
successfully test the application of reinforce-
by Adaboost is sign(F (x)).
ment learning to trade on a futures market
A surprising phenomenon associated with Adaboost is
simulator (U-Mart) of the large Japanese
that the test error of the strong rule (percentage of
industrial companies (J30) index.
mistakes made on new examples) often continues to
In this research we followed the tradition of the papers decrease even after the training error (fraction of mistakes
in this section that use machine learning algorithms to made on the training set) reaches zero. This behavior has
find profitable trading strategies, and build automated been related to the concept of a ‘margin’, which is simply
trading agents. We also examined a method to calibrate the value y F (x) (Schapire et al. 1998). While y F (x)40
the trading rules or technical indicators using a learning corresponds to a correct prediction, y F (x)4a40 corre-
algorithm. sponds to a confident correct prediction, and the confi-
The rest of the paper is organized as follows. Section 2 dence increases monotonically with a.
announces the methods used. Section 3 introduces the Friedman et al. (2000), followed by Collins et al. (2004),
model calibration process. Section 4 presents the trading suggested a modification of Adaboost, called Logitboost.
agent and its algorithm. Section 5 describes the data. Logitboost can be interpreted as an algorithm for
Section 6 explains in detail the experiments. Section 7 step-wise logistic regression. This modified version of
presents the results of our trading agent algorithm. Adaboost assumes that the labels yi are stochastically
Section 8 concludes, and the appendix introduces the generated as a function of xi. Then it includes Ft1(xi) in
main investment indicators used in this research. the logistic function to calculate the probability of yi,

yIntuitively, a weak learner is an algorithm with a performance at least slightly better than random guessing.
zMapping x to {0, 1} instead of {  1, þ1} increases the flexibility of the weak learner. Zero can be interpreted as ‘no prediction’.
Model calibration and automated trading agent 533

and easier to interpret than the rules generated by other


boosting decision tree learning algorithms such as CART
and C4.5. Additionally, ADT gives a measure of confi-
dence or classification margin that is very useful for
expert selection.

2.2. Bagging
Bagging was proposed by Breiman (1996) as a method
that reduces the variance of a prediction function. If the
Figure 1. The Adaboost algorithm (Freund and Schapire 1997).
yi is the binary label to be predicted, xi corresponds to the training set W consists of pairs (x1, y1), (x2, y2), . . . ,
features of an instance i, wti is the weight of instance i at time t, (xm, ym), xi corresponds to the features of an example,
and ht and Ft(x) are the prediction rule and the prediction score and yi is either a class label or a numerical response to be
at time t, respectively predicted. The predictor of y is (x, W). Bagging or
bootstrap aggregation generates uniform bootstrap sam-
ples with replacement of W. These samples and their
predictors are W(B) and (x, W(B)) respectively.
When yi is a numerical response, the final predictor is
obtained by the average of the predictors of the bootstrap
samples as

B ðxÞ ¼ avB ðx, ðBÞ Þ:


If yi is a class label, B(x) is obtained by the majority vote
of (x, W(B)).
Bagging has been shown to be particularly effective for
Figure 2. The Logitboost algorithm (Friedman et al. 2000). yi is
the binary label to be predicted, xi corresponds to the features of
reducing the variance of decision trees.
an instance i, wti is the weight of instance i at time t, and ht and
Ft(x) are the prediction rule and the prediction score at time t,
respectively. 2.3. Logistic regression
The logistic regression models (Hastie et al. 2003) the
posterior probabilities Pr(Y ¼ l | Xi) of L classes Y using
and the exponent of the logistic function becomes the linear regression in the observed values Xij of the input
weight of the training examples. Figure 2 describes variable Xi ¼ (Xi1, . . . , Xin) of the feature j:
Logitboost using notation similar to that used in figure 1. Pn
 X
A successful and popular way of using boosting is to e j¼1 ij ij
PrðY ¼ l j Xi Þ ¼ Pn :
combine it with a decision tree learning algorithm as the  X
1 þ e j¼1 ij ij
base learning algorithm (Friedman et al. 2000). We use
boosting both to learn the decision rules constituting the The summation of these probabilities equals one. Logistic
tree and to combine these rules through a weighted regression results are better interpreted using the
majority vote. The form of the generated decision rules is odds ratio:
called an alternating decision tree (ADT) (Freund and PrðY ¼ l j Xi Þ
Mason 1999). In ADTs, each node can be understood in :
PrðY ¼ L j Xi Þ
isolation.
In terms of boosting, each prediction node represents a In the current paper, L is two because we are trying to
weak prediction rule, and at every boosting iteration, evaluate if the price trend is positive or negative.
a new splitter node together with its two prediction nodes
is added to the model. The splitter node can be attached
to any previous prediction node, not only leaf nodes. 3. Model calibration using boosting
Each prediction node is associated with a weight  that
contributes to the prediction score of every example In contrast to econometric models where coefficients are
reaching it. The weak hypothesis h(x) is 1 for every defined by formal statistical models, trading rules and
example reaching the prediction node and 0 for all others. technical analysis require many parameters that, in many
We decided to use boosting, specifically Logitboost, as cases, are established by practitioners’ experience. Hence,
our learning algorithm because of its feature selection model calibration is one of the major practical problems
capability, its error bound proofs (Freund and Schapire that algorithmic trading may have, especially if it is based
1997), its interpretability, and its capacity to combine on technical analysis.
quantitative and qualitative variables. Additionally, we Genetic algorithms and simulated annealing are meth-
used ADT implemented with Logitboost because of its ods used by practitioners to calibrate technical trading
capacity to generate classification rules that are smaller models (Katz and McCormick 2000). Nunez (2007)
534 G. Creamer

applies a genetic algorithm to optimize the parameters In contrast to the previous references, this paper
used to calculate moving averages, although a trading proposes a high-frequency trading agent for equity
strategy derived from this indicator under-performs a index futures. This agent uses the expert weighting
simple buy-and-hold strategy for the two main indexes of algorithm introduced by Creamer and Freund (2010) to
the Madrid stock market (IBEX-35 and the General forecast a price trend as an input for a trading strategy
Index, IGE). Bodas-Sagi et al. (2009) use a genetic based on a variation of a market maker strategy proposed
algorithm multi-objective optimization model to calibrate by Creamer and Freund (2007). This approach forecasts
the moving average convergence divergence and the the price trend of the future using a machine learning
relative strength index indicators for the Dow Jones algorithm, and combines several investment signals as
index. well as the output of several experts using an online
Another approach is the ‘brute force’ method where a learning utility. Finally, it controls the level of risk using a
large number of alternatives are tested and the best option risk management overlay.
is selected. The problem with this perspective is that it is One of the strengths of our approach is that the
computationally intensive, and high-frequency data may algorithm optimizes the parameters of the technical
change significantly in different periods, possibly requir- analysis indicators as explained in section 3, defines new
ing continuous calibration. trading rules, and generates experts at different moments
The method that we evaluate in this paper, initially of the trading cycle. The main objective of this process is
explored by Creamer and Freund (2010), recalculates to ensure that the investment decision takes into account
every technical indicator n number of times using different old and new patterns of the time series under study, and
values of its parameters. All these different versions of the that there is an online learning process with the capacity
technical indicators become the input of the boosting to integrate the feedback of previous outcomes. The
algorithm. Boosting, based on its feature selection capa- online learning algorithm comes from Freund et al.
bility, will select a group of parameters and technical (2004), and from the weighted majority algorithm pro-
indicators that optimizes its evaluation function. The posed by Littlestone and Warmuth (1994) and further
initial parameters used in this research are those recom- studied by Cesa-Bianchi et al. (1997).
mended in the technical analysis literature. The objective of the algorithm is to predict the return of
the future contract in the next period. yt 2 [1, þ1] is the
binary label to be predicted where 1 represents the
4. Trading agent algorithm expectation of a positive return, and 1 otherwise.
The market maker trading strategy initially proposed
Agent-based economics is becoming a well recognized by Creamer and Freund (2007) starts with a long or short
methodology for market simulation. Main economics portfolio position based on a daily forecast of the market
conferences such as the Eastern Economics Association trend. During the day, the trading agent also sends
meeting include several sessions on agent-based econom- simultaneous buy and sell limit orders at prices slightly
ics (Barr et al. 2008, 2010). From a trading perspective, below and above the prices at the top of the buy and sell
the agent-based approach could be useful for backtesting order books. This strategy takes advantage of the former
new ideas without risking any money. The Santa Fe stock electronic market Island’s pricing policy: when a trade is
market modely has inspired many other agent-based executed, the trader that submitted the limit order shall
financial market models, such as Ehrentreich (2002), receive a rebate of $0.002, and the party that submitted
which is based on the Grossman and Stiglitz (1980) the incoming order shall pay a transaction fee of $0.003.
model. In the Santa Fe stock market, agents can classify During the week of January 5–9, 2004, an annualized
and explore several forecasting rules that are built using Sharpe ratio of 0.21 was established using the market
genetic algorithms. Many of the models built according to maker strategy, which is superior to the Sharpe ratio of
this perspective test the performance of agents or algo- 0.28 that was obtained using a constant rebalanced
rithms that have unique characteristics. For example, portfolio (CRP) strategy during the same period of time.
Lettau (1997) builds an agent-based financial market This market maker strategy is profitable because it
using simple agent benchmarks based on genetic algo- captures the bid–ask spread and also tries to get the
rithms; Gode and Sunder (1993) develop a double action maximum amount in rebates and the minimum amount in
market using zero intelligence traders; Arifovic (1996) fees. This strategy cannot be directly applied to products
builds a model of the foreign exchange market using traded at Eurex because this exchange does not offer
genetic algorithms; Routledge (2001) extends the basic rebates, instead the trading costs are slightly lower for the
framework of Grossman and Stiglitz (1980) with agents party that submitted the incoming order.
that can learn by using genetic algorithms; Chan et al. Our limit order trading strategy sends only one buy or
(1999) and Chan (2001) use the artificial market frame- sell limit order based on the futures return forecast, which
work to explore the behavior of different trading is updated every g periods of time (e.g. 30 minutes), and
approaches and their microstructure impact. the following rules.

yFor a presentation of the Santa Fe stock market model, see Arthur et al. (1997) and LeBaron et al. (1998), and a later version of
LeBaron (2001). LeBaron (2000) also has a general review of papers in the area of agent-based finance.
Model calibration and automated trading agent 535

. If the expected price trend is positive, it sends a Before expiration, both index futures are traded at their
buy limit order at a price slightly lower than the market values. If they are not used for hedging, the main
bid price at the top of the buy order book less decision variable for trade is the price trend. In this
transaction costs. If there is a short position, the respect, forecasting the futures price trend is a simple
size of the order is the short position. classification problem.
Otherwise, it is  futures contract. For every index future (FESX and FDAX) we have
. If the expected price trend is negative, it sends a trade and quote level 2 data. We recreated the order book
sell limit order at a price slightly higher than the at 10 second intervals, integrating the quotes (bid price,
ask price at the top of the sell order book plus bid volume, ask price, and ask volume) with the trades
transaction costs. If there is a long position, the (trade volume and trade price) for March 2009 (22 trading
size of the order is the long position. Otherwise, days). The previous prices were aggregated using volume-
it is  futures contract. weighted average prices (VWAP), and the volumes were
. If the order is not 100% filled within a fixed aggregated by a simple sum. The trades and quotes data
period (i.e. 1 minute) of being issued, existent were linked according to their time stamp. Mid-prices
limit orders are cancelled, and limit orders are were calculated as the average between the bid and
reissued according to current experts’ forecast. ask prices.
The position is liquidated at the end of every trading
day.
As part of its risk management capability, the trading 6. Experiments
agent eliminates any weak trading signal when it is below
a certain threshold, which is established during the 6.1. Model calibration
training and optimization stage. If the maximum draw- We evaluated the performance of the calibration method
down (D,t) (Dempster et al. 2001, Moody and Saffell proposed in section 3 with the FESX and FDAX index
2001), the largest potential loss in a certain period of time, futures, splitting these datasets into training (70%) and
passes a certain threshold, then the system holds its test (30%) datasets. The number of observations for
current position. training and test datasets are 68,995 and 29,536 for FESX
The maximum drawdown is calculated as and 68,913 and 29,501 for FDAX, respectively. We tested
: our calibration method with two technical indicators:
Dt ¼ maxðRtx  Rty j t0  tx  ty  tÞ,
momentum and Bollinger bands,y and with the combi-
where Rtx and Rty are the accumulated return from time t0 nation of all the indicators listed in the appendix (without
until time tx and ty, respectively. including the liquidity indicators). The dependent variable
The main reason to propose this risk management rule yt 2 [1, þ1] is a binary variable that has a value of
is that the trading agent should not invest further in an 1 when the return or trade price trend of the next period is
unprofitable strategy. However, it can reverse course, if positive, and a value of 1 otherwise. As a base case, we
the market conditions improve. Additionally, the algo- worked with a model calculated with the most common
rithm calculates the Sharpe ratio as a risk-adjusted return parameters for each indicator as used by practitioners and
indicator. The annualized Sharpe ratio (SRt) is also used listed in the appendix. The classification of the base case
as a weight for each observation is a majority vote of the respective rules of the
: ðRt Þ indicators used.
SRt ¼ : Our method includes the recalculation of the technical
ðRt Þ
indicators with different parameters. Besides the base
The complete algorithm is presented in figure 3. case, we tried three other variations where each parameter
is tested with three, six and nine different versions and
where their values increase by six, three and two units,
5. Data respectively. The main calculation of these indicators for
the model calibration and for the trading agent is done
The data used in this paper are the Dow Jones EURO using R, its financial engineering, order book, and
STOXX 50 Index Futures (FESX) and the DAX Futures analytics packages called Rmetrics, RTAQ and RWeka,
(FDAX). The Dow Jones EURO STOXX 50 and the respectively.z OneMetrics 5http://www.onetick.com4 is
DAX indexes represent the 50 largest European compa- used for the generation of the order book.
nies and the 30 major German companies traded on the Logitboost is used to classify the future trade price
Frankfurt Stock Exchange, respectively. These two future trend. To check for the possibility that the Logitboost
indexes were selected in consideration that they both results could be improved because of the characteristic
reflect the market expectation of the underlying indexes. instability of boosting, we ran bagging on top of
These indexes are highly liquid, especially FESX. These Logitboost (bagged boosting). We also compared
data were obtained directly from Eurex. Logitboost’s results with Adaboost and logistic regression

ySee appendix for an explanation.


zSee 5http://cran.r-project.org4 and 5http://www.rmetrics.org4 for information about R and Rmetrics, respectively.
536 G. Creamer

Figure 3. Trading agent algorithm. This is a modified version of the trading algorithm introduced by Creamer and Freund (2010).

to evaluate the difficulty of the classification task. We forecast and its impact in risk-adjusted return. Its
performed 10-, 50- and 100-fold cross-validation experi- application to a trading strategy is reviewed in the next
ments to evaluate classification performance on held-out section.
experiments. Logitboost, Adaboost and bagging are run
with 20 iterations. We compared our results using the test
6.2. Trading algorithm
error and the Sharpe ratio. For this test of model
calibration, the Sharpe ratio is calculated using a very The trading agent algorithm presented in figure 3 is
simple calculation of return based on the price difference applied to the FESX and FDAX futures. This algorithm,
between periods and the trend forecast. We did not implemented with Logitboost, reweights the participation
include trading costs because we were not testing any of each expert according to individual performance.
trading strategy. We were only evaluating the trend Additionally, the risk management module holds or
Model calibration and automated trading agent 537

liquidates positions when they are not profitable or algorithms explored have test errors between 44% and
become too risky. Every day, the trading agent processes 46%. The mean difference between the base case and all
new information and takes investment decisions based on the algorithms explored is significant at the 99% confi-
the experts generated the previous day. During the day, dence level when all the technical indicators are used.
new experts are generated about every half hour (d) and Similar results are obtained using 50 and 10 subsets.
substitute older experts, maintaining a maximum of These results are also consistent with the calculation of
25 experts (E). In our simulation, the first day was used the Sharpe ratio. The Sharpe ratio of the base case with
only to generate experts and the agent started to trade 100 subsets is respectively 5.26 and 19.29 for FESX and
only on the second day. Also, about every half hour (g), FDAX. All the learning algorithms show a positive
the agent evaluates the trend of the market and sends limit Sharpe ratio when all the indicators are used (see table 2)
orders according to the trading algorithm. The limit and the difference with the base case is significant with a
orders are revised every f periods of 10 seconds each. 99% confidence level. In all cases, the Sharpe ratio is
We evaluated f with the following values: 1, 2, 3, 4, 5, 6, 9, lower for the simulations when Bollinger bands and
12, 18, 24, 30, 36, 42, 48, 54, and 60. The threshold to momentum are tested independently.
eliminate very weak expert weights ( 0) is set to 0.20, and Logitboost and logistic regression running with all the
the threshold to restrict trading ( 1) is set to 0, as technical indicators show the highest Sharpe ratio for
suggested by Creamer and Freund (2010). both FESX and FDAX. Additionally, an increase in the
We decided to use boosting, specifically Logitboost, as number of versions (three or six) of the same technical
our learning algorithm because of its feature selection indicators improve the Sharpe ratio, while nine versions
capability, its error bound proofs (Freund and Schapire of each parameter leads to a deterioration of the Sharpe
1997), its interpretability, and its capacity to combine ratio in most cases. Boosting, the primary learning
quantitative and qualitative variables. Additionally,
algorithm, is able to handle a large number of parameters
Logitboost performed as well as or better than the rest
until a certain point. As Creamer and Freund (2010) have
of the algorithms tested during our model calibration
pointed out, the use of boosting for financial prediction
experiments. We used the implementation of boosting in
improves when relevant ratios that are known for their
Java included in the MLJAVA package or in its current
version called JBoost 5http://jboost.sourceforge.net4. importance to investment decisions are employed instead
A group of well-known technical indicators, and of using the original indicators.
investment signals introduced in the appendix are the It is more important from an algorithmic trading
inputs for the machine learning algorithm: a simple and perspective to concentrate on a risk-adjusted return
exponential moving average, Bollinger bands, accelera- indicator than on the accuracy of the algorithm. The
tion, momentum, rate of change, moving average con- simulations show that the evaluated algorithms may have
vergence divergence, relative strength index, on balance very different Sharpe ratios even though they could have a
volume, negative and positive volume index, price-volume very similar test error. This can be explained from the
trend and several liquidity indicators. We also included even weight given to all observations for the calculation of
ratios and trading rules suggested by the practice of the test error, while a risk-adjusted return indicator
technical analysis. considers the return and the volatility of the investment
The initial value of the parameters used to calculate the decision. So a correct forecast for two observations that
technical indicators are those recommended in the liter- have price changes of 2% and 0.002% will have the same
ature. Additionally, most of the technical indicators are impact in the calculation of the test error, while the first
calculated three extra times with parameters that increase observation adjusted by risk will have more importance in
by six units every time. Based on the result of our the calculation of the Sharpe ratio.
calibration model, the difference of performance with Logitboost also slightly outperforms bagging in the
other combinations was not very significant and our case of FESX, while bagging outperforms Logitboost
choice reduced the computation period. using FDAX data. So it does not seem necessary to incur
The results of the trading algorithm are aggregated in the additional computational cost of bagging when it does
21 trading days. We tested our results with trading costs not always generate superior results than Logitboost.
per futures contract of 0.3 EUR and 0.5 EUR for FESX In general, Logitboost is the best algorithm for FESX,
and FDAX, respectively. These values are consistent with while logistic regression and bagging may show better
Eurex’s prices. We compared our results with a buy-and- results in some cases for FDAX. Anyway, FESX is the
hold (B&H) position using the Sharpe ratio as a most important index and is much more liquid and traded
risk-adjusted return measure. than FDAX.
These results lead us to prefer Logitboost for our
trading agent algorithm. The annualized Sharpe ratio of
7. Results this algorithm is reported in table 3. It shows that the
Sharpe ratio for FESX and FDAX outperforms a simple
Table 1 shows that all the algorithms tested with FESX buy-and-hold strategy with a 99% confidence level.
and FDAX data perform better than the base case. With Additionally, orders submitted every 50 and 40 seconds
100 subsets, the base case has a test error of 49.65% for lead to the maximum Sharpe ratio for FSEX (40.17) and
FESX and 47.46% for FDAX, while most of the FDAX (41.59). Figure 4 shows graphically how the
538 G. Creamer
Table 1. Test error (%) by algorithm for (a) FESX and (b) FDAX. Each algorithm is tested with zero, three, six and nine
repetitions (Rep.) and with a modification of the original parameter (D) by zero, six, three, and two steps, respectively.

All indicators Bollinger bands Momentum


Models
# subsets Rep. D 100 50 10 100 50 10 100 50 10
(a) FESX
Base case 0 0 49.69 49.65 49.56 46.23 46.22 46.13 52.76 52.78 52.89
Adaboost 0 0 45.69 45.69 45.68 45.54 45.83 45.83 45.66 45.93 45.93
3 6 45.69 45.68 45.54 45.83 45.83 45.66 45.93 45.93 45.74
6 3 45.69 45.68 45.54 45.83 45.83 45.66 45.93 45.93 45.74
9 2 45.69 45.68 45.54 45.91 45.93 45.81 45.93 45.93 45.74
Bagging 0 0 44.50 44.48 44.36 45.81 45.8 45.64 45.96 45.96 45.78
3 6 44.31 44.31 44.22 45.94 45.92 45.76 45.92 45.92 45.74
6 3 44.34 44.33 44.23 46.00 46.01 45.87 45.92 45.92 45.74
9 2 44.65 44.64 44.54 45.87 45.86 45.71 45.93 45.93 45.75
Logistic 0 0 45.00 44.96 44.85 45.83 45.83 45.65 45.93 45.93 45.74
regression 3 6 45.78 45.73 45.74 45.85 45.85 45.66 45.92 45.92 45.73
6 3 46.93 46.93 46.96 45.94 45.95 45.78 45.92 45.92 45.74
9 2 45.95 45.93 45.93 45.87 45.87 45.73 45.94 45.93 45.75
Logitboost 0 0 44.53 44.52 44.43 46.18 46.2 46.09 45.95 45.97 45.78
3 6 44.52 44.51 44.43 45.84 45.83 45.66 45.84 45.83 45.65
6 3 44.36 44.35 44.30 46.13 46.14 46.04 46.03 46.03 45.89
9 2 44.41 44.41 44.35 45.95 45.92 45.83 45.99 46.00 45.74
(b) FDAX
Base case 0 0 47.46 47.32 47.22 49.1 49.1 48.99 51.61 51.58 51.73
Adaboost 0 0 44.74 44.73 44.69 47.68 47.68 47.55 47.30 47.18 47.18
3 6 44.59 44.58 44.55 47.41 47.41 47.29 46.25 46.17 46.11
6 3 44.80 44.79 44.66 47.54 47.51 47.39 46.26 46.23 46.11
9 2 44.59 44.58 44.55 47.46 47.45 47.34 46.23 46.15 46.13
Bagging 0 0 44.61 44.59 44.50 47.51 47.49 47.39 47.33 47.21 47.22
3 6 44.54 44.50 44.42 47.19 47.17 47.06 46.10 46.04 46.00
6 3 44.45 44.42 44.37 47.26 47.23 47.08 46.35 46.29 46.19
9 2 44.4 44.38 44.31 47.22 47.22 47.07 46.19 46.14 46.03
Logistic 0 0 44.55 44.50 44.47 47.60 47.58 47.48 46.85 46.74 46.79
regression 3 6 44.66 44.61 44.62 47.34 47.34 47.22 46.08 46.01 45.99
6 3 44.38 44.29 44.25 47.12 47.12 46.97 46.29 46.23 46.21
9 2 44.65 44.61 44.60 47.10 47.10 46.96 46.25 46.21 46.08
Logitboost 0 0 47.3 47.31 47.44 47.69 47.65 47.58 47.31 47.17 47.16
3 6 44.70 44.66 44.51 47.21 47.21 47.10 46.31 46.24 46.21
6 3 44.63 44.60 44.48 47.32 47.32 47.18 46.40 46.33 46.24
9 2 44.72 44.71 44.60 47.34 47.34 47.22 46.17 46.13 46.01
Note: 5%, 1% significance level ( p-value) of t-test difference between the base case and each algorithm.

cumulated return for FESX using orders submitted every combination of these parameters. The optimization
50 seconds outperforms the buy-and-hold strategy. method could be a learning algorithm with feature
We can also observe that the Sharpe ratios of the selection capability such as Logitboost. Our tests indicate
trading algorithm for FESX are larger than those that Logitboost outperforms a model that uses the typical
obtained from the model calibration process. These parameters recommended by investment practitioners.
differences are partially explained by different samples, The simulations show that the evaluation of a trading
and the additional use of liquidity indicators. However, algorithm should be based on risk-adjusted return indi-
the most important considerations are related to the cators instead of only using accuracy indicators such as
trading strategy itself: the test error. When a risk-adjusted return indicator is
(1) the combination of many experts that are utilized, every individual investment decision is evaluated
reweighted according to their performance, and by considering its return contribution and its risk impact
(2) the trading algorithm that uses the forecast of the while the test error gives the same weights to all the
price trend to profit from the bid–ask spread. observations. So it might be possible that a learning
algorithm has a low test error under normal conditions
while it may not be able to anticipate major market
8. Final comments and conclusions changes. As a result, its Sharpe ratio might be unsatis-
factory. Another algorithm might be able to take advan-
This paper shows that a trading agent can be calibrated tage of the instability of the market to capture profits
generating multiple versions of the same parameter or even though it may not show the best performance under
technical indicator and then selecting the optimal normal market conditions.
Model calibration and automated trading agent 539
Table 2. Sharpe ratio by algorithm for (a) FESX and (b) FDAX. Each algorithm is tested with zero, three, six and nine repetitions
(Rep.) and with a modification of the original parameter (D) by zero, six, three, and two steps, respectively.

All indicators Bollinger bands Momentum


Models
# subsets Rep. D 100 50 10 100 50 10 100 50 10
(a) FESX
Base case 0 0 5.26 5.41 7.28 6.13 6.37 5.82 0.03 0.2 2.6
Adaboost 0 0 8.41 8.84 9.12 3.79 3.43 3.65 1.08 1.58 3.06
3 6 8.41 8.84 9.12 3.79 3.43 3.65 1.08 1.58 3.06
6 3 8.41 8.84 9.12 3.79 3.43 3.65 1.08 1.58 3.06
9 2 8.41 8.84 9.12 12.39 11.65 9.90 1.08 1.58 3.06
Bagging 0 0 18.42 18.75 17.68 5.15 4.61 3.95 1.02 1.59 3.09
3 6 20.65 19.98 18.77 6.12 5.84 4.93 1.05 1.56 3.03
6 3 20.69 20.02 18.81 6.41 5.48 3.95 1.05 1.55 3.02
9 2 17.46 17.16 16.57 6.71 6.09 4.59 1.13 1.67 3.12
Logistic 0 0 13.04 12.65 11.17 3.07 2.48 1.78 1.08 1.58 3.06
regression 3 6 13.64 12.99 11.04 3.81 3.17 2.19 0.93 1.45 2.93
6 3 12.19 12.00 9.70 2.71 2.02 0.68 0.94 1.46 2.95
9 2 18.06 17.85 16.16 3.24 2.04 0.59 1.12 1.54 3.05
Logitboost 0 0 18.6 18.58 17.43 4.29 3.91 2.84 0.63 1.29 2.54
3 6 18.22 18.06 17.30 6.53 6.22 5.50 0.81 1.26 3.21
6 3 21.41 20.9 19.34 4.78 4.12 2.01 1.21 1.67 3.85
9 2 20.26 20.19 18.71 4.67 4.32 2.40 5.56 6.72 10.52
(b) FDAX
Base case 0 0 19.29 18.51 16.88 7.83 9.53 11.57 1.13 2.33 3.37
Adaboost 0 0 40.89 40.41 36.99 10.49 8.75 7.56 22.81 22.61 21.20
3 6 41.27 40.7 37.58 14.52 12.83 12.62 29.53 29.18 26.68
6 3 39.14 39.09 37.14 13.28 11.32 11.09 31.1 31.59 29.58
9 2 41.27 40.7 37.58 13.88 12.06 11.9 31.25 30.9 29.30
Bagging 0 0 40.76 40.14 37.92 11.4 9.35 8.08 22.54 22.34 20.91
3 6 40.47 39.78 37.13 16.66 14.33 13.43 31.65 31.98 29.76
6 3 41.74 41.03 37.99 15.73 13.29 12.44 30.95 31.46 29.7
9 2 42.29 41.53 38.33 15.74 13.37 12.25 31.81 31.83 30.67
Logistic 0 0 42.2 41.87 38.59 10.07 8.69 7.66 23.91 23.99 21.98
regression 3 6 42.94 42.94 40.13 15.14 12.87 11.07 32.03 32.11 29.53
6 3 44.55 44.42 41.69 15.97 13.4 12.35 32 32.47 30.34
9 2 41.15 41.41 38.74 15.77 13.29 11.96 31.99 31.65 29.95
Logitboost 0 0 11.85 11.71 8.59 11.52 10.05 8.97 22.48 22.31 21.02
3 6 39.78 39.14 36.54 16.41 14.33 12.48 30.44 30.25 28.07
6 3 40.19 39.43 36.75 15.81 13.63 12.05 30.58 30.88 29.22
9 2 38.62 37.83 35.89 15.91 13.54 11.78 31.41 31.16 29.88
Note: 5%, 1% significance level (p-value) of t-test difference between the base case and each algorithm.

The trading agent algorithm introduced in this paper


Table 3. Annualized Sharpe ratio for FESX and FDAX using
21 trading days of March 2009. t-Test of mean difference generated positive returns for two major European index
between the underlying return series for the trading strategy and futures (FESX and FDAX) using high-frequency data.
B&H has a significance level (p-value) of 1%. This trading agent was able to obtain these results
combining a learning algorithm that makes the predic-
Seconds between orders FESX FDAX
tion, an expert weighting algorithm that combines
10 23.55 21.43 experts, a risk management layer that minimizes risky
20 39.33 39.69 trades, and a trading strategy that uses the prediction to
30 38.06 38.73 profit from the bid–ask spread.
40 35.12 41.59
50 40.17 35.08
High-frequency trading has a different market struc-
60 36.01 34.77 ture and dynamic than daily or monthly trading. Hence,
90 36.86 34.61 an automated trading strategy that works for longer
120 37.48 40.32 periods of time may not work for high-frequency data or
180 34.53 35.56 it must be adjusted accordingly. Intraday data may not
240 34.61 38.42
300 34.36 39.37
change much in very short periods of time unless it is
360 34.04 36.83 affected by special events. As a result, a trading agent
420 34.29 36.83 may need many experts that capture changes in the
480 34.24 35.24 market behavior in different time periods. Additionally,
540 33.22 36.83 the trading agent may have to review the order period-
600 33.56 35.24
B&H 1.42 3.02 ically (e.g. every 5 or 30 minutes) and define minimum
quality standards to reduce excessive trading.
540 G. Creamer

Bates, R., Dempster, M.A.H. and Romahi, Y.S., Evolutionary


reinforcement learning in FX order book and order flow
analysis. In Proceedings of the IEEE International Conference
on Computational Intelligence for Financial Engineering,
Hong Kong, March 20–23, pp. 355–362, 2003 (IEEE:
Hong Kong).
Bodas-Sagi, D.J., Fernández, P., Hidalgo, J.I., Soltero, F.J. and
Risco-Martı́n, J.L., Multiobjective optimization of technical
market indicators. In Proceedings of the 11th Annual
Conference Companion on Genetic and Evolutionary
Computation Conference: Late Breaking Papers,
pp. 1999–2004, 2009 (ACM: New York).
Bollerslev, T., Generalized autoregressive conditional hetero-
scedasticity. J. Econometr., 1986, 31, 307–327.
Figure 4. Cumulative return of algorithmic trading strategy and Bollinger, J.A., Bollinger on Bollinger Bands, 2001
B&H for March 2009. Values are indexed to 1. (McGraw-Hill: New York).
Breiman, L., Bagging predictors. Mach. Learn., 1996, 24,
123–140.
Our algorithm can be enriched by the introduction of Cesa-Bianchi, N., Freund, Y., Haussler, D., Helmbold, D.P.,
Schapire, R.E. and Warmuth, M.K., How to use expert
new types of indicators that capture either events or advice. J. ACM, 1997, 44(3), 427–485.
market relationships that affect market behavior. Chan, N., LeBaron, B., Lo, A. and Poggio, T., Agent-based
Recently, several data providers have offered machine- models of financial markets: A comparison with experimental
readable news, parsed and transformed into investment markets. MIT Artificial Markets Project (No. 124),
Cambridge, MA, 1999.
signals, that can be used as new predictive variables or as Chan, T., Artificial markets and intelligent agents. Massachusetts
an input to uncover relationships between companies and Institute of Technology, Cambridge, MA, 2001.
economic trends that may improve the forecasting capa- Chande, T.S. and Kroll, S., The New Technical Trader: Boost
bility of our predictive model. Your Profit by Plugging into the Latest Indicators, 1994
(Wiley: New York).
Choi, J.H., Lee, M.K. and Rhee, M.W., Trading S&P500 stock
index futures using a neural network. In Proceedings of the
3rd Annual International Conference on Artificial Intelligence
Acknowledgements Applications on Wall Street, pp. 63–72, 1995.
Clayburg, J.F., Four Steps to Trading Success: Using
The author thanks Stephanie Hammer, Axel Vischer and Everyday Indicators to Achieve Extraordinary Profits, 2001
(Wiley: New York).
the Eurex team in Chicago for providing the data and for Collins, M., Schapire, R.E. and Singer, Y., Logistic regression,
discussing initial versions of this research. The author also AdaBoost and Bregman distances. Mach. Learn., 2004,
thanks Ionut Florescu, H. Eugene Stanley, Jeff 48(1–3), 253–285.
Nickerson, participants of the Eurex workshop at the Creamer, G. and Freund, Y., A boosting approach for
University of Chicago, and at the High Frequency data automated trading. J. Trading, 2007, 2(3), 84–95.
Creamer, G. and Freund, Y., Automated trading with boosting
conference at Stevens Institute of Technology for sugges- and expert weighting. Quantit. Finance, 2010, 10(4), 401–420.
tions and informal discussions about the trading algo- Dempster, M.A.H. and Leemans, V., An automated FX trading
rithm, to OneMarketData, Maxim Chernobayev, Maria system using adaptive reinforcement learning. Expert Syst.
Belianina, and Ross Dubin for making OneTick available Applic.: Special Issue on Financial Engineering, 2006, 30,
534–552.
for this research, and to Patrick Jardine for proof-reading
Dempster, M.A.H., Payne, T.W., Romahi, Y. and
the article. The opinions presented are the exclusive Thompson, G.W.P., Computational learning techniques for
responsibility of the author. intraday FX trading using popular technical indicators.
IEEE Trans. Neural Networks, 2001, 12, 744–754.
Duke, L.S. and Long, J.A., An application of the AQ machine
learning methodology on the stock market. In Adaptive
Intelligent Systems: Proceedings of the BANKAI Workshop,
References Brussels, Belgium, 12–14 October 1992 ,edited by the Society
for Worldwide Interbank Financial Telecommunication S.C,
Allen, F. and Karjalainen, R., Using genetic algorithms to find 1993 (Elsevier: Amsterdam).
technical trading rules. J. Financ. Econ., 1999, 51(2), 245–271. Ehlers, J.F., Rocket Science for Traders: Digital Signal
Arifovic, J., The behavior of the exchange rate in the genetic Processing Applications, 2001 (Wiley: New York).
algorithm and experimental economies. J. Polit. Econ., 1996, Ehrentreich, N., The Santa Fe artificial stock market re-
104(3), 510–541. examined – Suggested corrections. econWPA, 2002.
Arthur, W.B., Holland, J.H., LeBaron, B., Palmer, R. and Fosback, N., Stock Market Logic: A Sophisticated Approach to
Talyer, P., Asset pricing under endogenous expectations in an Profits on Wall Street, 1991 (Dearborn Trade Publishing:
artificial stock market. In The Economy as an Evolving Chicago).
Complex System II, edited by W.B. Arthur, S. Durlauf, and Freund, Y., Mansour, Y. and Schapire, R., Generalization
D. Lane, pp. 15–44, 1997 (Addison-Wesley: Reading, MA). bounds for averaged classifiers. Ann. Statist., 2004, 32(4),
Barr, J., Tassier, T. and Ussher, L., Symposium introduction. 1698–1722.
East. Econ. J., 2008, 34(4), 421–422. Freund, Y. and Mason, L., The alternating decision tree
Barr, J., Tassier, T. and Ussher, L., Introduction to the learning algorithm. In Machine Learning: Proceedings of the
symposium on agent-based computational economics. Sixteenth International Conference, pp. 124–133, 1999
East. Econ. J., 2010, 37(1), 1–5. (Morgan Kaufmann Publishers Inc.: San Francisco).
Model calibration and automated trading agent 541

Freund, Y. and Schapire, R.E., A decision-theoretic general- Sherry, C.J., The New Science of Technical Analysis, 1994
ization of on-line learning and an application to boosting. (Probus Publishing: Chicago).
J. Comput. Syst. Sci., 1997, 55(1), 119–139. Shin, K-s., Kim, K-j. and Han, I., Financial data mining using
Friedman, J., Hastie, T. and Tibshirani, R., Additive logistic genetic algorithms technique: Application to KOSPI 200. In
regression: A statistical view of boosting. Ann. Statist., 2000, Proceedings of the Korea Inteligent Information System
38(2), 337–374. Society Conference, pp. 113–122, 1998 (Korea Intelligent
Gode, D.K. and Sunder, S., Allocative efficiency of markets Information Systems Society).
with zero intelligence traders: Market as a partial substitute Stridsman, T., Trading Systems and Money Management, 2003
for individual rationality. J. Polit. Econ., 1993, 101(1), (McGraw-Hill: New York).
119–137. Tay, F. and Cao, L., Application of support vector machines in
Granville, J., Granville’s New Key to Stock Market Profits, 2000 financial time series forecasting. Omega, 2001, 29, 309–317.
(Prentice Hall: Upper Saddle River). Towers, N. and Burgess, A.N., Implementing trading strategies
Grossman, S. and Stiglitz, J., On the impossibility of informa- for forecasting models. In Computational Finance. Proceedings
tionally efficient markets. Am. Econ. Rev., 1980, 70, 393–408. of the Sixth International Conference on Computational
Hamid, S. and Iqbal, Z., Using neural networks for forecasting Finance, New York, 6–9 January 1999, edited by
volatility of S&P 500 Index futures prices. J. Business Res., Y.S. Abu-Mostafa, B. LeBaron, A.W. Lo and
2004, 57, 1116–1125. A.S. Weigend, pp. 313–325, 2000 (MIT Press:
Hastie, T., Tibishirani, R. and Friedman, J., The Elements of Cambridge, MA).
Statistical Learning, 2003 (Springer: New York). Trippi, R.R. and DeSieno, D., Trading equity index futures with
Holland, J., Adaptation in Natural and Artificial Systems, 1975 a neural network. J. Portfol. Mgmt, 1992, 19(1), 27–33.
(University of Michigan Press: Ann Arbor). Tsaih, R., Hsu, Y. and Lai, C.C., Forecasting S&P 500 Stock
Katz, J. and McCormick, D., The Encyclopedia of Trading index futures with a hybrid AI system. Decis. Support Syst.,
Strategies, 2000 (McGraw-Hill: New York). 1998, 23(2), 161–174.
Kim, K., Artificial neural networks with feature Witkowska, D. and Marcinkiewicz, D., Construction and
transformation based on domain knowledge for the predic- evaluation of trading systems: Warsaw index futures.
tion of stock index futures. Int. J. Intell. Syst. Account. Int. Adv. Econ. Res., 2005, 11, 83–92.
Financ. Manage., 2004, 12(3), 167–176. Zivot, E. and Wang, J., Modeling Financial Time Series with
Kim, K., Artificial neural networks with evolutionary instance S-Plus, 2003 (Springer: New York).
selection for financial forecasting. Expert Syst. Applic., 2006,
30, 519–526.
Koza, J.R., Genetic Programming: On the Programming of
Computers by Means of Natural Selection, 1992 (MIT Press:
Cambridge, MA). Appendix A: Investment signals
LeBaron, B., An evolutionary bootstrap method for selecting
dynamic trading strategies. In Decision Technologies for Technical indicators quantify market trends. We follow
Computational Finance, Proceedings of the Fifth International Zivot and Wang (2003) and Creamer and Freund (2010)
Conference Computational Finance, edited by A.-P.N.
Refenes, A. Burgess and J. Moody, pp. 141–160, 1998 in describing the technical analysis indicators. Additional
(Springer: New York). useful references about technical analysis and trading are
LeBaron, B., Agent based computational finance: Suggested Chande and Kroll (1994), Sherry (1994), Katz and
readings and early research. J. Econ. Dynam. Control, 2000, McCormick (2000, Clayburg (2001), Ehlers (2001),
24, 679–702.
LeBaron, B., Empirical regularities from interacting long and
Pring (2002) and Stridsman (2003).
short memory investors in an agent-based financial market. We index the trading period by t ¼ 1, 2, . . . . We denote
t b a
IEEE Trans. Evolut. Comput., 2001, 5, 442–455. by Ptt , Pbt , Pat , Pm
t , VOLt , VOLt , and VOLt the trade, bid,
LeBaron, B., Arthur, W.B. and Palmer, R., The time series ask, and mid-price, and the trade, bid, and ask volume.
properties of an artificial stock market. J. Econ. Dynam. We are trying to predict the trend of Ptt .
Control, 1998, 21, 1487–1516.
Lettau, M., Explaining the facts with adaptive agents: The case We eliminate the lower index when we wish to refer to
of mutual funds flows. J. Econ. Dynam. Control, 1997, 21, the whole sequence, i.e. Pt refers to the whole
1117–1148. sequence Pt1 , Pt2 , . . ..
Littlestone, N. and Warmuth, M.K., The weighted majority Many of the technical indicators incorporate the
algorithm. Informat. Comput., 1994, 108, 212–261. following simple or exponentially weighted moving aver-
Lo, A., Mamaysky, H. and Wang, J., Foundations of technical
analysis: Computational algorithms, statistical inference, and ages of prices. Let X denote a time sequence X1, X2, . . ..
empirical implementation. J. Finance, 2000, 4, 1705–1765. The simple moving average is defined as
Moody, J. and Saffell, M., Learning to trade via direct
reinforcement. IEEE Trans. Neural Networks, 2001, 12(4), 1Xn1
875–889. SMAt ðX, nÞ ¼ Xts ,
Moriyama, K., Matsumoto, M., Fukui, K-i., Kurihara, S. and n s¼0
Numao, M., Reinforcement learning on a futures market
simulator. J. Univ. Comput. Sci., 2008, 14(7), 1136–1153. and the exponentially weighted moving average is
Núñez, L., Fitting the control parameters of a genetic algorithm:
defined as
An application to technical trading systems design. Eur. J.
Oper. Res., 2007, 179(3), 847–868.
Pring, M., Technical Analysis Explained, 4th ed., 2002
X
1
2
EMAt ðX, nÞ ¼  ð1  Þs Xts , ¼ :
(McGraw-Hill: New York). nþ1
s¼0
Routledge, B.R., Genetic algorithm learning to choose and use
information. Macroecon. Dynam., 2001, 5, 303–325.
Schapire, R.E., Freund, Y., Bartlett, P. and Lee, W.S., Boosting EMAt(X, n) can be calculated using a simple update rule:
the margin: A new explanation for the effectiveness of voting
methods. Ann. Statist., 1998, 26(5), 1651–1686. EMAt ðX, nÞ ¼ Xt þ ð1  ÞEMAt1 ðX, nÞ:
542 G. Creamer

Rules associated with technical indicators are denoted by moving average. Most of these ratios are part of the
‘rule’ and followed by an identification number. The input trading rules. However, we include the ratios by them-
to our trading agent algorithm includes both signals and selves so that our learning system finds its own rules.
normalized indicators. In table A1 we describe the technical indicators. The
Additionally, we recalculate a selected group of indi- parameters of each indicator are in parentheses. Most of
cators and their rules with three different values of the the parameters used refer to the length of the period (n)
main parameters that are close to the industry practice. selected to calculate the indicator. In the case of the
So, our learning system should be able to select the exponential moving average, the parameter used is ,
optimal combination of indicators and parameters. which also depends on n. We have assigned parame-
We also include ratios of the indicators which generally ters that are typically used in the industry for each
are calculated as the indicator divided by its indicator.

Table A1. Investment and technical indicators.

Variable Price indicators: Description Calculation detail


EMAct ðÞ Exponential moving average of a EMAt(Pc, ) where  ¼ 0.9, 0.84, and 0.78
time series Pt
rule1t Exponential moving average to EMAct ðÞ=Pc
price ðPtt Þ
SMAct ðnÞ Simple moving average of the last SMAt(Pc, n) where n ¼ 10, 16 and 22
n observations of a time series
Pt
rule2t Simple moving average to Ptt SMAct ðnÞ=Pc where n ¼ 10, 16 and 22
Bollinger bands: Using the moving average or the Bollm c
t ðnÞ ¼ SMAt ðnÞ
median band (Bollm t ðnÞ) as the
reference point, the upper and
lower Bollinger (Bollinger 2001)
bands (Bollut ðnÞ and Bolldt ðnÞ,
respectively) are calculated as a
function of s standard devia-
tions. When the price crosses
above (below) the upper (lower)
Bollinger band, it is a sign that
the market is overbought
(oversold). Technical analysts
typically calculate Bollinger
bands using 20 periods for the
moving average and two stan-
dard deviations.
2
Bollut ðnÞ Upper Bollinger band Bollmt ðnÞ þ st ðnÞ where s ¼ 2, n ¼ 20, 26 and 32
2
Bolldt ðnÞ Lower Bollinger band Bollmt ðnÞ  s t ðnÞ where s ¼ 2, n ¼ 20, 26 and 32
PBollut ðnÞ Price to upper Bollinger band Ptt =Bollut ðnÞ
PBolldt ðnÞ Price to lower Bollinger band Ptt =Bolldt ðnÞ
rule3t 8
t d t u
>
< Buy if Pt1  Bollt ðnÞ and Pt 5 Bollt ðnÞ
Bollinger trading rule Sell t t
if Pt1  Bolld ðnÞ and Pt 4 Bollut ðnÞ
t
>
:
Hold Otherwise
Momentum and oscillation indicators:
MOMt(n) Momentum: price ðPtt Þ change in Ptt  Pttn where n ¼ 12, 18, and 24
the last n periods. When it
crosses above (below) zero, it
indicates that the trend is up
(down). The default value of n
is 12
MomEM At(n, ) Momentum to MOMt(n)/EMAt(MOMt(n)) where n ¼ 12, 18, and 24
EMAt(MOMt(n), ) and  ¼ 0.75
rule4t 8
>
> Buy if MOMt1 ðnÞ  EMAt ðMOMt ðnÞ;Þ
>
>
Momentum trading rule >
> and MOMt ðnÞ4 EMAt ðMOMt ðnÞ;Þ
<
Sell if MOMt1 ðnÞ  EMAt ðMOMt ðnÞ;Þ
>
>
>
> and MOMt ðnÞ5 EMAt ðMOMt ðnÞ;Þ
>
>
:
Hold Otherwise :

(continued )
Model calibration and automated trading agent 543
Table A1. Continued.

Variable Price indicators: Description Calculation detail


rule5t 8
>
> Buy if ACCELt1 ðnÞ þ 1  0
>
>
Acceleration trading rule >
> and ACCELt ðnÞ þ 1 4 0
<
Sell if ACCELt1 ðnÞ þ 1  0
>
>
>
> and ACCELt ðnÞ þ 1 5 0
>
>
:
Hold Otherwise
ROCt(n) Rate of change: rate of change of
Ptt . Technical analysts recom-
mend using 10 periods to cal- ½ðPtt  Pttn Þ=Pttn   100
culate this indicator where n ¼ 10, 16, and 22
rule6t 8
< Buy
> if ROCt1 ðnÞ  0 and ROCt ðnÞ 4 0
ROC trading rule Sell if ROCt1 ðnÞ  0 and ROCt ðnÞ 5 0
>
:
Hold Otherwise
MACDt(s, f) Moving average convergence EMAt(Pt, s)  EMAt(Pt, f) where f ¼ 12, and s ¼ 18, 24,
divergence: difference between and 30
two moving averages of slow
and fast periods (s, f).
MACDt(s, f) is regularly calcu-
lated using 26 (s) and 12 (f)
periods
MACDSt(s, f, n) MACD signal line: moving aver- EMAt(MACDt(s, f), n where f ¼ 12, n ¼ 9, and s ¼ 18,
age of MACDt(s, f) of past n 24, and 30
periods. A buy (sell) signal is
generated when MACDt(s, f)
crosses above (below) the signal
line or a threshold
rule7t 8
>
> Buy if MACDt1 ðs, fÞ  MACDSt ðs, f, nÞ
>
>
MACD trading rule >
> and MACDt ðs, fÞ 4 MACDSt ðs, f, nÞ
<
Sell if MACDt1 ðs, fÞ  MACDSt ðs, f, nÞ
>
>
>
> and MACDt ðs, fÞ 5 MACDSt ðs, f, nÞ
>
>
:
Hold Otherwise
MACDRt(s, f, n) MACDt(s, f) to MACDSt(s, f, n) MACDt(s, f)/MACDSt(s, f, n)
RSIt(n) Relative strength index: compares 100  1þ½SMAt ðPup , n100 dn where n1 ¼ 8, 14, and 20
1 Þ=SMAt ðP , n1 Þ
the periods that stock prices n n

finish up against those periods and n is the length of the time series

that stock prices finish down. Ptt if Ptt 4 Ptt1
Technical analysts calculate this Pup
t ¼
empty Otherwise
indicator using nine, 14 or 25 
periods. A buy signal is when Ptt if Ptt 5 Ptt1
Pdn
t ¼
RSIt(n) crosses below a lower empty Otherwise
band of 30 (oversold), and a sell Pup up up up up
n ¼ ðPtn , Ptnþ1 , Ptnþ2 , . . . , Pt Þ
signal when RSIt(n) crosses
dn dn dn dn
above an upper band of 70 Pdn
n ¼ ðPtn , Ptnþ1 , Ptnþ2 , . . . , Pt Þ
(overbought)
rule8t 8
< Buy
> if RSIt1 ðnÞ  30 and RSIt ðnÞ 5 70
RSI trading rule Sell if RSIt1 ðnÞ  30 and RSIt ðnÞ 4 70
>
:
Hold Otherwise
Volatility and return indicators:a
r^tþ1 , t2 Next period return and volatility
calculated using GARCH(1, 1)
(Bollerslev 1986)
Sharpe ratio Risk-adjusted return r^t =t2
Volume indicators:
OBVt On balance volume: this indicator
was developed by Granville
(2000) to evaluate the impact of if Ptt 4 Ptt1 OBVt ¼ OBVt1 þ VOLtt
positive and negative volume if Ptt 5 Ptt1 OBVt ¼ OBVt1  VOLtt
flows. OBVt adds the volume

(continued )
544 G. Creamer
Table A1. Continued.

Variable Price indicators: Description Calculation detail


when the close price has
increased and subtracts it when
the close price has decreased.
A sign of market reversal is
when OBVt diverges with the
price movement

NVIt and PV It Negative and positive volume


index: these indicators were
introduced by Fosback (1991)
as signals of bull markets. NVIt if VOLtt 5VOLtt1 NVIt ¼ NVIt1 þ ROCt ðnÞNVIt1
(PVIt) concentrates on periods
PVIt ¼ PVIt1
when volume decreases
(increases). The rationality is if VOLtt  VOLtt1 PVIt ¼ PVIt1 þ ROCt ðnÞPVIt1
that ‘informed’ investors take NVIt ¼ NVIt1
positions in periods when where n ¼ 1
volume decreases, while the
‘uninformed’ investors take
position in periods when the
volume increases. NVIt (PVIt)
is calculated as the cumulative
sum of ROCt(n) when volume
decreases (increases). Fosback
maintains that there is a 95%
probability that a bull market is
going to develop when NVIt
crosses above its one year
moving average, and a 67%
probability of a bear market
when PVTt crosses below its
one year moving average
rule9t 8
<Buy if NVIt1 SMAt ðNVI, l Þ
and NVIt 4 SMAt ðNVI, l Þ
Negative volume index :Hold Otherwise
trading rule

rule10t 8
>
> Buy if PVIt1  SMAt ðPVI, l Þ
>
>
Positive volume index >
> and PVIt 4 SMAt ðPVI, l Þ
<
trading rule Sell if PVIt1  SMAt ðPVI, l Þ
>
>
>
> and PVIt 5 SMAt ðPVI, l Þ
>
>
:
Hold Otherwise

nviSMAt(l) NVIt to SMAt(NVI, l) where l ¼ 10


NVIt/SMAt(NVI, l), where l ¼ 10
pviSMAt(l) PVIt to SMAt(PVI, l) PVIt/SMAt(PVI, l), where l ¼ 10
PVt(n) Price-volume trend: this indicator
is similar to OBVt. It calculates X
n
VOLtt ROCt ðn1 Þ
the cumulative total of volume t¼1
where the portion of volume
added/subtracted is given by where n1 ¼ 1
the increase or decrease of close and n is the length of the time series.
prices in relation to the previ-
ous period
Liquidity indicatorsb
ESt Effective spread 2  Dt  ðPtt  Pm
t Þ, where Dt if trade is buy 1, sell 1

RSt Realized spread 2  Dt  ðPtt  Pm


tþ300 Þ, where time is in seconds

VTt Value trade Ptt  VOLtt


SVTt Signed value trade Dt  Ptt  VOLtt
STSt Signed trade size Dt  VOLtt

(continued )
Model calibration and automated trading agent 545
Table A1. Continued.

Variable Price indicators: Description Calculation detail

Dt ðVOLat VOLbt Þ
dDIt Depth imbalance as difference VOLat þ VOLbt
DIt Depth imbalance as ratio ðVOLat =VOLbt ÞD
100ESt
PESt Proportional effective spread Pmt
100RSt
PRSt Proportional realized spread Pmt
ESt RSt
PIt Price impact 2
100PIt
PPIt Proportional price impact Ptm

HTSt Half traded spread Dt  ðPtt  Pm


tþ300 Þ, where time is in seconds
HTSt
PHTSt Proportional half traded spread Pm
t

RetSQt Squared log return on trade prices ðlogðPtt Þ  logðPtt1 Þ2 Þ


RetAbst Absolute log return on trade j logðPtt Þ  logðPtt1 Þj
prices
QSt Quoted spread Pat  Pbt
QSt
PQSt Proportional quoted spread Pm  100
t  
Pa
LogQSt Quoted spread log Ptb
t

LogSizet Log quoted spread logðVOLat Þ  logðVOLbt Þ


QSt
QSlopet Quoted slope LogSizet
logðQSt Þ
LogQSlopet Log quoted slope LogSizet
2
MQRetSQ Squared mid-quote returns ðlogðPm m
t Þ  logðPt1 ÞÞ

MQRetAbs Absolute mid-quote returns j logðPm m


t Þ  logðPt1 Þj

Notes: aGARCH is also another indicator of volatility.


b
Only used for the trading algorithm. Liquidity indicators are not used for the model calibration tests described in section 6.1.

You might also like