Professional Documents
Culture Documents
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
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
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
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
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
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.
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.
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.
(continued )
Model calibration and automated trading agent 543
Table A1. Continued.
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.
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
(continued )
Model calibration and automated trading agent 545
Table A1. Continued.
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