11 Automatic Trading: Winning or Losing in a...

18
11 Automatic Trading: Winning or Losing in a kBit * Key words: random walk, AR(1), GARCH, bootstrapping, technical analysis, Monte Carlo simulation Technical analysis focuses on historical information concerning price movements in order to forecast future price trends. In this manner, technical analysts argue that changes in the psychology of the market can be used to profit from trading. With technical analysis profits can be obtained in two different ways. Under a first ap- proach, the analyst purely relies on charting and “reads” historical price trajectories to find clues on trend reversals. Under a second approach, the role of the analyst is reduced. An automatic trading system uses historical information to implement a trading process governed by a set of well-defined rules, while traders just need to choose the strategy to implement. Despite its long history (one of the first attempts to forecast stock prices is at- tributed to Charles H. Dow in the late 1800s), academics have traditionally regarded technical analysis with a mixture of suspicion and contempt (see, for instance, Fama and Blume (1966), Fama (1969) and Jensen and Benington (1970)). In fact the ef- ficient market paradigm holds that in capital markets all relevant information is re- flected in current prices. Therefore, for traditional researchers, trading rules based on past prices are meaningless. But with the accumulation of evidence on the inef- ficiency of many marketplaces, 1 the idea that some technical rules can be used to systematically gain profits from trading has acquired momentum. An important con- tribution in this sense has come from Brock et al. (1992) (BLL henceforth). Using a set of simple technical rules, these authors first investigated sixty years of the Dow Jones Index and achieved statistically significant profits. Since then, several authors have tried to replicate BLL’s results on different data sets and periods. For instance, Hudson, Dempsey and Keasey (1996) have used data from the United Kingdom. with Carlo Pozzi and Federico Roveda. 1 A list of references can be found in Lo, MacKinlay and Zhang (1997), pp. 43–44.

Transcript of 11 Automatic Trading: Winning or Losing in a...

Page 1: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11

Automatic Trading: Winning or Losing in a kBit*

Key words: random walk, AR(1), GARCH, bootstrapping, technical analysis,Monte Carlo simulation

Technical analysis focuses on historical information concerning price movements inorder to forecast future price trends. In this manner, technical analysts argue thatchanges in the psychology of the market can be used to profit from trading. Withtechnical analysis profits can be obtained in two different ways. Under a first ap-proach, the analyst purely relies on charting and “reads” historical price trajectoriesto find clues on trend reversals. Under a second approach, the role of the analystis reduced. An automatic trading system uses historical information to implement atrading process governed by a set of well-defined rules, while traders just need tochoose the strategy to implement.

Despite its long history (one of the first attempts to forecast stock prices is at-tributed to Charles H. Dow in the late 1800s), academics have traditionally regardedtechnical analysis with a mixture of suspicion and contempt (see, for instance, Famaand Blume (1966), Fama (1969) and Jensen and Benington (1970)). In fact the ef-ficient market paradigm holds that in capital markets all relevant information is re-flected in current prices. Therefore, for traditional researchers, trading rules basedon past prices are meaningless. But with the accumulation of evidence on the inef-ficiency of many marketplaces,1 the idea that some technical rules can be used tosystematically gain profits from trading has acquired momentum. An important con-tribution in this sense has come from Brock et al. (1992) (BLL henceforth). Using aset of simple technical rules, these authors first investigated sixty years of the DowJones Index and achieved statistically significant profits. Since then, several authorshave tried to replicate BLL’s results on different data sets and periods. For instance,Hudson, Dempsey and Keasey (1996) have used data from the United Kingdom.

∗ with Carlo Pozzi and Federico Roveda.1 A list of references can be found in Lo, MacKinlay and Zhang (1997), pp. 43–44.

Page 2: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

312 11 Automatic Trading: Winning or Losing in a kBit

Bessembinder and Chan (1995) have tested emerging markets in the Asian area.More recently, Isakov and Hollistein (1999) have studied the Swiss market, whileDetry and Grégoire (2001) have concentrated on several European indexes.

In this chapter, we provide a review of a few well-known techniques. Our trea-tise is organized as follows. Section 11.2 illustrates the chosen technical strategiesand the statistical tests conducted to assess the statistical significance of their actualprofits. In particular, we focus on the MACD-H indicator and a development of themoving average crossover. According to the procedure suggested by BLL, we testour results using a bootstrap methodology. Section 11.3 presents the VBA R© codeused to run our strategy. In Sect. 11.4, we discuss our results testing the proposedtechnical rule on the five largest capitalized stocks in the US equity market.

11.1 Problem Statement

The technical strategy we analyze in this chapter is named moving average conver-gence divergence (MACD). In our treatise, we depart from BLL, who consider twoof the most simple and known classes of technical rules based on the crossover oftwo moving averages,2 and present the MACD technique which is a trend-followingmomentum indicator originally developed by Appel and Hitschler (1980). Illustra-tions of this indicator can also be found in Murphy (1999) and – in a more detailedfashion – in Thorp (2000). Given its relatively old age, the MACD rule has long beenknown to technical analysts. For this reason, we deem that it may be regarded as themethodology free of data snooping biases.

The MACD indicator combines two exponential moving averages of past pricesinto two lines: the MACD line and the signal line. The MACD line is constructedas the difference between two exponential moving averages computed using last m

and n closing prices, where m and n are integers such that n > m.3 It follows thatthe MACD line crosses the zero line each time there is a crossover between the twomoving averages. To see this, let Pt be the market closing price at day t , and letus define a long-period and a short-period exponential moving average, EMALt andEMASt respectively, as

EMALt = 1

nPt +

(1 − 1

n

)EMALt−1, EMAL0 = P0, t = 1, 2, . . . ,

EMASt = 1

mPt +

(1 − 1

m

)EMASt−1, EMAS0 = P0, t = 1, 2, . . . ,

and let the MACD line, MACDt , be defined as the difference between EMALt andEMASt ,

2 The rule is: “initiates buy (sell) signals when the short run moving average is above (below)the long run moving average”.

3 Exponential averages are a standard tool in technical analysis. They are preferable to arith-metic averages because they respond more quickly to changes in price. Indeed more weightis placed on the most recent prices, whilst arithmetic averages give the same weight to allrecorded prices.

Page 3: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.1 Problem Statement 313

MACDt = EMASt − EMALt , MACD0 = 0, t = 1, 2, . . . .

It is easy to observe that, since the fast moving average (EMASt on m-periods) re-flects the short-period trend in the market while the slow moving average (EMALt onn-periods) reflects the long-period tendency, when the short-period moving averageis above the long-period moving average, MACDt is positive. This may be interpretedas a bullish market phase. The opposite is true when the fast moving average is dom-inated by the long one. The MACD is thus a trend-follower algorithm. It performsat its best during strong trending periods, but tends to lose money during periodsof choppy trading (i.e., when prices move sideways for several weeks). A trigger orsignal line, named SLt , is also used. SLt is a k-period exponential moving average ofthe MACD line

SLt = 1

kMACDt +

(1 − 1

k

)SLt−1, SL0 = 0, t = 1, 2, . . . .

Taking the difference between the MACD and the signal line we obtain the MACD-Histogram (MACDH) indicator, the importance of which consists in highlightingvariations in the spread between the fast and the slow lines,

MACDHt = MACDt − SLt .

When the histogram lies above (below) the zero line but starts to fall (increase) to-wards the zero line, then the up trend (down trend) is losing momentum (the dis-tance between fast and slow moving averages is decreasing. According to the MACDrules, a buy (sell) signal is generated each time the MACD line moves above (below)the signal line or alternatively when the MACDH crosses the zero line from below(above). In this way, one is always active in the market, since on the closing of aposition, a new one can be opened with the opposite sign. For this reason this tradingsystem is classified into the category Stop and Reverse.

Histogram zero crossovers can also be used to detect early exit signals from ex-isting positions. Indeed, MACD tracks whether the market is gaining or losing mo-mentum, measuring the acceleration or deceleration between moving averages andsignaling if a stock or index has been overbought or oversold. Therefore, MACD isnot only a lagging indicator, but also a leading indicator which can be used to detectexcesses of demand or supply in the market. Prudence is however recommended,since using MACD turns in order to initiate new positions can be quite dangerous asit implies opening positions against prevailing market trends (Murphy (1999)).

Unlike other oscillators, like the relative strength index or the stochastic index,MACD it is not constrained between upper and lower bounds, but it can hit new highsor lows as long as price trends are gaining momentum. In the finance practice, themost popular parameters in the MACD and MACDH computations are m = 12, n =26 and k = 9 periods. They are also set as default values in many software packages.In this chapter, the VBA R© code takes into account the possibility of having one setof numbers for buy signals and another for sell signals. We follow here the originalsuggestion of Appel and Hitschler (1980) who recommended using an asymmetriccombination of 8-17-9 for buy signals and 12-26-9 for sell signals.

Page 4: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

314 11 Automatic Trading: Winning or Losing in a kBit

11.2 Model and Solution Methodology

11.2.1 Measuring Trading System Performance

The possibility of discerning between different trading strategies (TS) is provided bythe measurement of their performance. A detailed analysis of this topic is given bySchwager (1996), Chapter 21. In these pages, as standard measure of performance,we use the cumulative sum of all profits and losses generated by a TS. We define thisnet measure as the difference between all the profits (total gross profit) and losses(total gross loss) obtained over a given period of time. With these two quantities, wealso calculate a risk measure for our TS by dividing the total gross loss by the totalgross profit. This ratio is called profit factor – namely, the expected reward on oneunit of capital invested in the TS. Profit factors are then employed to rank alternativeTS. Once this is done, a common rule among practitioners is to discard strategieswith profit factors below two. The total number of trades has also a bearing on tradingperformance. Another rule of thumb in this case is to consider ten to twenty tradesper year.

Other useful quantities may supplement comparisons between TS: (1) the aver-age trade, (2) the average winning trade, (3) the average losing trade, (4) the averagewinning/losing trade ratio, (5 and 6) the largest winning trade and the largest los-ing trade. Let us examine them separately. (1) The average trade is the average netprofit across all trades. (2 and 3) The average winning (losing) trade is the averageprofit (loss) across all winning (losing) trades. Low values for the average winningtrade imply high vulnerability to mistakes. (4) The average winning/losing trade ra-tio is an additional measure of TS risk and so are the following two. (5 and 6) Infact, the largest winning (losing) trade should be read in conjunction with the grossprofit (loss) of a TS: if a large part of it comes from a single trade, a strategy may beconsidered as risky. Therefore, a single trade should not exceed 1/4 of gross profits(losses). However, in the opposite case, tracking the largest loss is not recommendedas a unique measure of risk because it may bias performance judgements by magni-fying the importance of a single negative event. This is particularly significant in theevaluation of managers with long track records, since large losses occur with morefrequency over longer periods of time.

A significant historical performance measure is then maximum drawdown. Thisquantity measures the largest decline (peak-to-valley) from the highest equity value,tracked over s days prior to the sample period considered. In other words, it repre-sents the top cumulative loss an investor would have incurred, had they invested atthe worst possible prior time (i.e., the prior equity peak) and stayed long throughthe sample period considered. Maximum drawdown can thus be seen as the largestmargin necessary to cover the highest possible loss produced by a TS. This measureis computed as

MDT = − max0≤t≤T

{max

0≤s≤tπs − πt

},

where πt represents cumulative profits up to time t . As a descriptive statistic, maxi-mum drawdown has one key positive aspect and some important limitations. Vis-à-vis volatility, it is an observable quantity measuring a capital requirement. This can

Page 5: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.2 Model and Solution Methodology 315

be expected to be smaller either when the upward price drift is steeper or when thevariability of the process is lower. But being derived from a single string of data,maximum drawdown is exposed to large errors. For this reason, it may be biasedwith respect to means determined across multiple periods. Moreover, the longer thetime series considered, the greater a drawdown is likely to be. A fact which suggeststhat it would be wise to compare drawdowns only across TS with track records ofthe same length.

The maximum number of losing trades is yet another measure of risk. This num-ber counts how many consecutive losing trades an investor should accept beforeabandoning a TS. The psychological importance of this number is evident. It is thuspreferable to establish it before beginning a trading scheme.

Finally, an important benchmark is the one way break-even trading (BET) mea-sure. This quantity, suggested by Bessembinder and Chan (1998), represents the levelof transaction costs that eliminates all profits achieved through a TS in excess of asimple buying and holding strategy. It is computed as

bet = 2π

N, (11.1)

where π is the average profit of the strategy and N is the total number of signals(purchases and sales).

11.2.2 Statistical Testing

As suggested in BLL, it is possible to conduct statistical tests on TS at two levels ofdepth. At a first stage, one can compare profits coming from buy and sell trades. Iftechnical analysis does not have any power in predicting market trends, then profitson buy days should not differ from profits on sell days. Therefore we can use standardstatistical tests and compare means and variances on buy versus sell days. Similartests can be conducted to compare profits generated by the technical strategy andby a passive one, for instance the buy-and-hold position. For example, by using thet-statistic we can see if the mean buy and mean sell profits are significantly different.The t-statistic is

t (b,s) = μb − μs

(σ 2b /Nb + σ 2

s /Ns)1/2,

where μb (μs), σ 2b (σ 2

s ) and Nb (Ns) are respectively the mean profit, the numberof signals and the variance of profits for buys (sells). The test which checks if theglobal mean daily profit is significantly different from the daily unconditional profitis given by the t-statistic

t(str,b&h) = μstr − μb&h

(σ 2str/Nstr + σ 2

b&h/Nb&h)1/2,

where “str” and “b&h” refer to the strategy and to the buy-and-hold position.These tests assume normal, stationary and time-independent distributions. These

assumptions are however too strong compared to the stylized facts which affect stock

Page 6: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

316 11 Automatic Trading: Winning or Losing in a kBit

return distributions and time series (such as their high kurtosis and their conditionalheteroskedasticity). Standard statistical tests can thus give misleading results. Asa result, at a second stage, a possible solution is to bootstrap data, following theanalyses of Efron (1979), Freedman and Peters (1984), and Efron and Tibshirani(1986). A review of bootstrap applications in finance can be found in Maddala andLi (1996). In the following pages we present an approach which proceeds as follows:

1. Assume a return generating model (e.g., random walk, AR(1), GARCH(1, 1),etc.) and estimate it on a data set.

2. Standardize residuals from the estimated model. Under the null hypothesis thatthe return model is the true generating process, standardized residuals should berealizations of i.i.d. innovations.

3. Re-sample with replacement estimated standardized residuals and use them asinnovations to simulate a new price history of the same length as the original.

4. Apply the trading strategy to the bootstrapped series.5. Repeat the procedure n times (BLL set n = 500) and obtain the empirical distri-

butions of the mean profit of the TS under the chosen return generating model.6. Compute the fraction of simulated strategies which have greater mean or standard

deviation than the strategy applied to the original series. These fractions can beinterpreted as p-values. For example, if only 1% of the simulations generated bythe chosen model gives a mean return higher than the TS applied on the originalseries, then the p-value is equal to 1%. In other words, the probability that thechosen model generates the mean return obtained by the trading strategy on theoriginal series is only 1%. Therefore, the mean returns of the trading rule cannotbe explained by the assumed model.

By using the bootstrapping procedure, standardized residuals are not restricted to aparticular distribution and we can test the technical strategy against different models.Moreover, when we reject the null hypothesis for a given model specification, we cantest another one with few assumptions. Here we start testing the random walk (RW)model. RW simply assumes independence and identical distribution for returns, butdoes not assume their normal distribution,

rt = εt , εt are i.i.d.

With the RW model, the bootstrapping procedure can be performed directly on theoriginal return series. If this model is rejected, in order to investigate if serial corre-lation in returns can explain the profits from the trading rule, we can then consideran AR(1) model,

rt = a + brt−1 + εt , t = 1, . . . , T ,

εt are i.i.d.: E(εt ) = 0, Var(εt ) = σ 2ε .

This model can be estimated with OLS. If a, b and σε are the estimated parameters,we can then compute standardized residuals from

εt = rt − a − brt−1

σε

.

Page 7: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.3 Code 317

Subsequently, we can re-sample from εt , ηt = εk(t), t = 1, . . . , T , where k(t) is auniform random number over the integers 1, . . . , T , and we construct new return andprice histories,

rt = a + brt−1 + ηt ,

Pt = Pt−1 exp(rt ).

We apply the TS on each simulation and we compute the fraction of simulated returnswhich have higher mean or standard deviation than the ones obtained by applyingthe same TS on the original series. These fractions can be interpreted as p-values. Ifthis model is also rejected, we can ask if conditional changes in variances can be apossible explanation for trading rule profits. Therefore we can re-specify the returnmodel as a GARCH(1, 1):4

rt = μ + εt , εt are i.i.d. ∼ N(0, ht ),

ht = ω + αε2t−1 + βht−1.

Once the GARCH(1, 1) has been estimated, we standardize estimated residuals

zt = rt − μ√ht

,

and then re-sample them with replacement

ηt = zk(t)

to form a new simulated series

rt = μ +√

ht ηt ,

ht = ω + αε2t−1 + βht−1,

Pt+1 = Pt exp(rt ).

Each simulation is based on n replications of the chosen return model. For eachsimulation, the same trading rule is applied. Then we compute the p-values and wedecide if any of the specified models can explain the trading rule profits.

11.3 Code

The trading system and the bootstrap methodology presented above have been imple-mented in VBA R©. We first run a historical analysis of our strategy. This can be donewith the VBA R© macro StartTradingSystem(). Once this macro is called, theuser form “Trading System” is shown. See Fig. 11.1.

In the form, the user has to indicate:

4 Brooks et al. (1998) have considered a more general GARCH-M model, in order to takeinto account changes in the conditional mean.

Page 8: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

318 11 Automatic Trading: Winning or Losing in a kBit

Fig. 11.1. Excel user form for starting the Trading System.

1. The path name of the file containing the historical data (the Browse button helpsin finding the correct folder path). Data must be stored as comma separatedfiles (.csv) and with the same field structure as downloads from Yahoo! Finance.Therefore, the .csv file must have seven columns that respectively refer to: date,opening price, maximum price, minimum price, closing price, volume and ad-justed closing price. The macro only imports dates and adjusted closing prices,which will serve as a basis for the strategy to be implemented. The macro sortsdata in the time series starting from the oldest one.

2. The name of the worksheet where the results of the strategy will be printed out. Ifno name is specified, the macro assigns by default the name “MACD”. This work-sheet will be created anew by the VBA R© macro, so no other existing worksheetshould have the same name as the one assigned here.

3. Parameters m, n and k to be used for the computation of the MACD. By default,the program assigns 12-26-9. However, the user can chose different periods andeven adopt an asymmetric strategy, specifying different parameters to be consid-ered for sale and purchase signals, as suggested by Appel and Hitschler (1980).

4. By clicking on OK, the form runs the following macros:a. UploadingData() to import data into a temporary worksheet.b. TradingRules() to apply the strategy. The VBA R© code is very simple:

If MACDH(t) > 0 And MACDH(t-1) < 0 ThenClose short and Go longElseIf MACDH(t) < 0 And MACDH(t-1) > 0 ThenClose long and Go shortEnd If

Page 9: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.3 Code 319

Fig. 11.2. Flow chart describing the macro StartTradingSystem().

c. PerformanceTable()to print the performance summary in the new work-sheet.

In particular, MACDH(t) in the macro is computed by the VBA R© function MACD-Histogram(vMACDHistogram() As Double, intSMA As Integer,intLMA As Integer, intSignal As Integer, Price() As Dou-ble). The entire procedure is described in the flowchart which appears in Fig. 11.2.The worksheet containing the performance summary, described in Sect. 11.2.1, isshown in Fig. 11.3. Finally, the value of the account, once the position has beenclosed, is reported in columns I (entire strategy), J (long position) and K (short posi-tions).

The VBA R© macro StartBootstrapSimulation() performs the boot-strap testing. Once this macro is run, the user form “Bootstrap Simulation” is shown.This user form appears in Fig. 11.4. In particular, in this one the user has to indicate:

1. The path name of the file containing historical data.2. The name of the worksheet where the results of the bootstrap simulation will be

shown.3. The parameters to be used for the computation of the MACD.

Page 10: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

320 11 Automatic Trading: Winning or Losing in a kBit

Fig

.11.

3.E

xcel

wor

kshe

etill

ustr

atin

gth

epe

rfor

man

cem

easu

res

ofth

etr

adin

gru

le.

Page 11: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.3 Code 321

Fig. 11.4. Excel user form for starting the Boostrap Simulation.

4. The number of simulations.5. The model assumed as return generator process. The user can choose between

RW, AR(1) and GARCH(1, 1).6. By clicking the OK button, the user form runs the following macros:

a. UploadingData() to import data into a temporary worksheet;b. It estimates the return model and runs the bootstrap simulation. In particular,

the function RandomWalk(vSimulated() As Double, Current-Price As Double, vReturn() As Double) estimates the randomwalk model; the AR(1) model is estimated using OLS by the function Au-toRegressive(vSimulated() As Double, CurrentPrice AsDouble, vReturn() As Double; the GARCH(1, 1) model is estima-ted by the function GARCH(vSimulated() As Double, Current-Price As Double, vReturn() As Double, dblMhu As Dou-ble, dblVar0 As Double, dblOmega As Double, dblAlphaAs Double, dblBeta As Double). The estimation is performed bymaximizing the likelihood function using the Excel Solver. The above func-tions return the vector vSimulated() containing a new bootstrapped series;

c. It prints the performance measures of the trading rule applied to the bootstrapsimulation in the new worksheet.

The entire procedure is described in the flowchart appearing in Fig. 11.5. Theworksheet with the results of bootstrap simulations is shown in Fig. 11.6. Results are

Page 12: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

322 11 Automatic Trading: Winning or Losing in a kBit

Fig. 11.5. Flow chart describing the procedure of the macro StartBoostrapSimulation().

presented as follows: in the first column, the number of the simulation is reported.Then we have the number of buy days, the number of short days, the conditional oneday return for the strategy, for purchases, for sales, the conditional daily standarddeviation for the strategy, for purchases, for sales, then the ratio between the condi-tional return and standard deviation, for the strategy, for longs, for sales, and finallythe one-way break-even trading.

11.4 Results and Comments

In this section we report the results of the trading system previously described. Inparticular, we consider either the symmetric case with default parameters 12-26-9, orthe asymmetric case with parameters 12-26-9 for opening long positions and 8-17-9for opening short positions. Time series data have been downloaded from Yahoo!

Page 13: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.4 Results and Comments 323

Fig

.11.

6.E

xcel

wor

kshe

etsh

owin

gth

ere

sults

ofth

ebo

otst

rap

sim

ulat

ion.

Page 14: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

324 11 Automatic Trading: Winning or Losing in a kBit

Table 11.1. Summary description of the data set

Stock Ticker Period Number of obs.Citigroup Inc. C 1/3/00–12/31/04 1256Exxon Mobil Corp. XOM 1/3/00–12/31/04 1256General Electric Co. GE 1/3/00–12/31/04 1256Microsoft Corp. MSFT 1/3/00–12/31/04 1256Pfizer Inc. PFE 1/3/00–12/31/04 1254Wal-Mart Stores Inc. WMT 1/3/00–12/31/04 1256

Table 11.2. Descriptive statistics of daily logarithmic returns

Stock Mean Std. dev. Skew. Kurt. JBC 0.00029 0.02228 −0.28379 8.01079 1330XOM 0.00034 0.01586 0.02424 6.48061 634GE −0.00016 0.02146 0.07536 6.06037 491MSFT −0.00053 0.02541 −0.20537 9.21079 2026PFE −0.00009 0.02003 −0.29621 5.57845 365WMT −0.00016 0.02099 0.13127 5.51836 335

Finance (http://finance.yahoo.com). In particular, we have examined the six largestcap stocks in the US market (Citigroup Inc. (Yahoo Ticker: C), Exxon Mobil Corp.(XOM), General Electric Co. (GE), Microsoft Corp. (MSFT), Pfizer Inc. (PFE) andWal-Mart Stores Inc. (WMT)), over a period of five years from January 3, 2000to December 31, 2004. Notice that the application of the trading strategy to singlestocks avoids measurement errors due to non-synchronous reporting of prices in theindex components and the problems related to trading the index.5 On the other hand,we are exposed to data snooping bias related to the arbitrary choice of the stocks,although their large market capitalization should reduce this problem. Tables 11.1and 11.2 provide summary information on the data set and on the distribution of thelogarithm return series. In particular, the last column in Table 11.2 gives the Jarque–Bera statistic that measures deviations from normality. This is the case for all stocks.6

Indeed, all of them have fat tails (a kurtosis higher than 3) and an asymmetric shape(positive or negative skewness).

Tables 11.3, 11.4 and 11.5 report some performance measures for the buy andhold position and for the TS. In particular Table 11.4 considers the symmetric case,whilst in Table 11.5 we consider the asymmetric case. In both cases, the results arevery disappointing in respect to the buy-and-hold strategy. Figure 11.7 illustratesthe dynamic of the cumulative profits of the trading rule applied to the six differentlistings. Only for Microsoft Corp. the strategy does generate an appreciable profitfactor of 1.7488 in the symmetric case and a remarkable 2.0017 in the asymmetric

5 This is issue is discussed in detail in Sweeney (1988).6 In particular, under the null hypothesis of a normal distribution, the Jarque–Bera statistic is

distributed as a chi-square with 2 degrees of freedom. The critical value at 1% level for theJarque–Bera statistic is 9.2103. Therefore, we reject the hypothesis of normal distributionat the 1% significance level.

Page 15: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.4 Results and Comments 325

Table 11.3. Summary performance measures of the buy-and-hold position

YT TNP ($) MAD ($) PF AWT ($) AWL ($ )C 14.76 2.74 1.04 0.63 0.63XOM −8.32 17.90 0.98 0.57 0.55GE 17.60 0.71 1.07 0.43 0.44MSFT −24.96 24.41 0.92 0.47 0.50PFE −3.40 19.53 0.99 0.52 0.53WMT −11.90 13.53 0.98 0.82 0.79

YT = Yahoo ticker; TNP = Total net profit; MAD = Maximum account drawdown;PF = Profit factor; AWT = Average winning trade; AWL = Average losing trade.

Table 11.4. Summary performance measures of the symmetric trading rule 12-26-9

YT TNP ($) MAD ($) PF AWT ($) AWL ($)C −7.81 16.64 0.88 2.85 1.90XOM −13.17 13.34 0.72 1.52 1.04GE −5.13 27.80 0.92 2.45 2.05MSFT 23.79 8.13 1.75 2.42 1.22PFE −22.18 25.91 0.61 2.08 1.55WMT −49.78 63.74 0.50 2.53 2.57

YT = Yahoo ticker; TNP = Total net profit; MAD = Maximum account drawdown;PF = Profit factor; AWT = Average winning trade; AWL = Average losing trade.

Table 11.5. Summary performance measures of the asymmetric trading rule 12-26-9; 8-17-9

YT TNP ($) MAD ($) PF AWT ($) AWL ($)C −5.01 22.20 0.93 2.70 1.96XOM −10.47 15.23 0.78 1.25 1.09GE −28.25 29.49 0.64 2.34 1.84MSFT 29.89 7.44 2.00 2.13 1.10PFE −39.62 39.62 0.50 1.73 1.89WMT −48.14 73.88 0.56 2.84 2.46

YT = Yahoo ticker; TNP = Total net profit; MAD = Maximum account drawdown;PF = Profit factor; AWT = Average winning trade; AWL = Average losing trade.

case, whilst in the buy-and-hold case the profit factor is only 0.92. These resultsseem to indicate that for Microsoft Corp. the proposed technical strategy can identifyprofitable opportunities. In order to investigate their statistical significance, we shallconduct some tests.

At first, we conduct a standard t-test to compare the daily mean profit of theactive (TS) and passive (buy-and-hold) strategies. In practice, the test is conductedon the series obtained as difference between daily profits under the two alternatives.Therefore, we test if the mean difference is equal to zero. The results of this testare given in Table 11.6. No statistically significant difference is obtained. Similarresults are obtained in the asymmetric case and for the t-test that compares long

Page 16: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

326 11 Automatic Trading: Winning or Losing in a kBit

Fig. 11.7. Equity lines of the trading rule for Exxon Mobil Corp. (XOM), Microsoft Corp.(MSFT) and Wal Mart Stores Inc. (WMT).

Table 11.6. Summary performance measures of the asymmetric trading rule 12-26-9; 8-17-9

μts−bh σts−bh N t-test (μts−bh �= 0)C −0.0054 1.1359 1254 −0.1690XOM −0.0033 0.7991 1254 −0.1484GE 0.0106 1.1228 1254 0.3358MSFT 0.0009 1.0384 1254 0.0307WMT 0.0504 1.5450 1254 1.1555

versus short positions (these results are not reported here). Our results collide withthe ones presented by BLL, who rejected the null hypothesis that technical rules donot have significant positive performance. However (as discussed in Sect. 11.2.2),since our results can be affected by the violation of the normal, stationary and time-independent assumptions, we conduct a bootstrap simulation along the lines of theprevious section. Figure 11.8 illustrates the density function of simulated mean re-turns (1,500 simulations) under the GARCH(1, 1) and of average profit obtained onthe original series (black triangle on the horizontal axis).

In Tables 11.7, 11.8, 11.9, we report the p-values of the bootstrap simulation forthe three models (RW, AR(1), GARCH(1, 1)), i.e. the fraction of simulations gener-ating a mean daily return or standard deviation or Sharpe ratio higher than the samestatistics obtained from the actual series.7 In particular, we distinguish results for thestrategy and for the long and short only positions. For example, the number 15%in Table 11.7 under the headings Strategy and Mean indicates that only 15% of thesimulated random walks generated a mean return as large as that from the original

7 We compute the Sharpe ratio as ratio between mean return and its standard deviation.Therefore we assume a zero risk-free rate.

Page 17: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

11.4 Results and Comments 327

Fig. 11.8. Distribution of simulated mean returns (1500 simulations) under the GARCH(1, 1)

and on the original series (black triangle on the horizontal axis).

Table 11.7. Summary performance measures of the asymmetric trading rule 12-26-9; 8-17-9

Strategy Buy SellMean 18% 25% 30%Std. dev. 47% 95% 12%Sharpe ratio 17% 22% 34%

Bootstrap results for MSFT: Random walk model: rt= εt .

Table 11.8. Summary performance measures of the asymmetric trading rule 12-26-9; 8-17-9

Strategy Buy SellMean 16% 20% 30%Std. dev. 48% 97% 12%Sharpe ratio 15% 15% 34%

Bootstrap results for MSFT: AR(1) model: rt = a + brt−1+ηt . AR(1) parameters: a =−0.0005376, b = −0.0257838.

series. Considering different return models, we remark that we never obtain a p-valuegreater than 36% for the mean returns. BLL obtained instead much stronger results.Indeed, their p-values, computed across a much wider set of trading rules applied tothe Dow Jones time series, were only occasionally greater than 11%. Instead, simi-larly to their results, the three models are unable to explain the volatility during buyand sell periods. This can be realized looking at the p-values for the TS and for thebuy and sell positions. For example, 98% (7%) under the headings Std. Dev. and Buy(Sell) in Table 11.7 means that in 98% (7%) of the simulations, the buy (sell) volatil-ity was higher (higher) than in the original series. If we consider the TS (buy + sell)the return models generate a volatility comparable to the original series (p-values of47%, 50% for RW and AR(1)) or much higher (p-value of 84% for GARCH(1, 1)).These results are reflected in Sharpe ratios that are in general higher in the origi-

Page 18: 11 Automatic Trading: Winning or Losing in a kBitfin.shufe.edu.cn/finance/citibank/金融工程与金融经济学... · 11 Automatic Trading: Winning or Losing in a kBit* Key words:

328 11 Automatic Trading: Winning or Losing in a kBit

Table 11.9. Summary performance measures of the asymmetric trading rule 12-26-9; 8-17-9for MSFT

Strategy Buy SellMean 20% 26% 36%Std. Dev. 85% 98% 38%Sharpe Ratio 17% 22% 37%Bootstrap results for MSFT: GARCH(1, 1) model: rt = μ + εt , ht = ω + αε2

t−1 + βht−1.

GARCH(1, 1) parameters: μ = 0.0002341, h0 = 0.0009691, ω = 0.0000014,α = 0.0863395, β = 0.9186362.

Table 11.10. Convergence of simulated p-values for the GARCH model

Number of simulations Mean St. dev. Sharpe ratio500 20% 84% 19%750 20% 85% 18%

1000 21% 86% 19%1250 19% 85% 18%1500 20% 83% 19%

nal series vis-à-vis those generated by the return models (p-values of 15%, 13% and19%). Therefore, the higher returns generated by the trading rule are not explainedby a higher risk (measured by the standard deviation). In conclusion, our results onthe performance of the TS are not so strong as in BLL, but they seem to suggest thatthe three chosen models fail to replicate the returns generated by the trading rule.In other words, the rule generates signals that are not likely to be explained by thereturn models. Nonetheless, these results are not robust to the presence of transactioncosts. Indeed, if we compute the break-even transaction cost (Eq. (11.1)), only if wetrade with transaction costs lower than 0.00266%, we can obtain a positive profit.Moreover, for the remaining stocks, whose results we do not report here, the returnmodels always generate Sharpe ratios higher than in the original series.

Finally, we investigate the sensitivity of the bootstrap results to the number ofsimulations on our results. As remarked in BLL, this test is important since the as-ymptotic properties of the bootstrap applied to GARCH models are not known. InTable 11.10 we report the same figures as in Table 11.9 for the GARCH model, butvarying the number of simulations. We can observe that the p-values obtained with500 simulations are reliable. Considering additional simulations produces little im-provement in the estimation of the p-values. Similar conclusions were also presentedin BLL.