enario 3. The varying risks associated with eachgame have to do with the diversification of the risk of flipping the coin.In Scenario 1, I have the ability to lose all ten coin flips, resulting in a lossof $10. The probability of this happening is 0.4510, or 0.03 percent. In Scenario 2,I can also lose $10, but to do so I must lose 100 flips. The probability of this eventis 0.45100, which is so small that it requires scientific notation to express its value.In Scenario 3, it would take flipping 1000 tails in a row to lose $10. This probability (0.451000) is so small that calculating usually generates errors on most PCs.As you can see in Figure 5.1 below, by flipping more and more times, it becomesmore and more unlikely that the adverse event of losing $10 occurs.While the probability of losing $10 becomes less likely as the number of flipsis increased and the bet size is decreased, so too does the probability of winning$10. The probability distributions of the winnings associated with the three gamesare displayed in Figure 5.2. As the number of flips increases and the size of eachbet decreases, the distribution of our profit and loss narrows and eventually converges at $1. The casino mimics this example every day. Although any single bet is
Distribution of Profits70%60%Playing 1000 times
Occurrence
50%40%30%Playing 100 times
20%
Playing 10 times10%
9
10
8
7
6
5
4
3
2
1
0
–1
–2
–3
–4
–5
–6
–7
–8
–9
–10
0%
Profit
FIGURE
5.1
Distribution of Profits. The distribution of profits is higher depending on how many times we play thegame.
PART 1 Structural Foundations for Improving Technical Trading
102
Outcome
10 flips
100 flips
1000 filps
⫺10 to ⫺8
0.4502%
0.0000%
0.0000%
⫺8 to ⫺6
2.2890%
0.0000%
0.0000%
⫺6 to ⫺4⫺4 to ⫺2
7.4603%15.9568%
0.0000%0.1820%
0.0000%0.0000%
⫺2 to 0
23.4033%
18.0908%
0.0847%
0 to +2+2 to +4
23.8367%16.6478%
68.3018%13.3494%
99.8518%0.0635%
+4 to +6
7.6303%
0.0760%
0.0000%
+6 to +8+8 to +10
2.0724%0.2533%
0.0000%0.0000%
0.0000%0.0000%
FIGURE
5.2
Table of Distribution of Profits. The distribution of profits is higher depending on how many times weplay the game.
largely random, the casino’s edge is quite predictable when spread over many independent bets.If each of the three scenarios generates the same expected return, then ourtrue preference is to engage in the scenario with the least amount of risk. We seethat as we spread our risk around many smaller bets, our risk is diminished. WhenI play blackjack at a casino, my bet is so inconsequential compared to all themoney changing hands that night, that my good fortune is more than likely goingto be canceled by some poor fellow’s bad luck. Actually, the casino’s biggest riskis a high roller whose bets are so large that they overwhelm the diversification ofthe smaller bettors. Sound familiar to trading?
DON’T PUT ALL YOUR EGGS IN ONE BASKETAlthough the practice of diversification has been employed for thousands of yearsby casinos and betting houses, the concept is relatively new in the world offinance. In the early 1900s stocks with risky business outlooks and bonds with lessthan ideal credit standing were largely avoided due to their risk. Harry Markowitz,a University of Chicago graduate student, began to think about this problem in the1950s within a completely quantitative framework. His work has led him to thetitle “Father of Modern Finance” and the 1990 Nobel Prize in Economics. In a nutshell, Markowitz asked the following:If stock A returns on average 10 percent per year with annualized standarddeviation of 20 percent, and stock B returns on average 10 percent per yearwith annualized standard deviation of 20 percent, then what is the return andrisk of holding a portfolio of 50 percent stock A and 50 percent stock B?
CHAPTER 5 Performance of Portfolios
103
The expected return of the 50-50 portfolio is still 10 percent. As it turns out,if stock A and B are not correlated, then the risk of the 50-50 portfolio is reducedto a standard deviation of 14 percent, lower than the 20 percent standard deviationof any stock by itself.Markowitz’s work led to a complete rethinking of the value of risky assets. Ifwe can package stocks with risky prospects into a diversified portfolio, then wemight be able to reduce most of the risk due to any one company. The result is aportfolio with less risk than any single asset within the portfolio. In essence, wehave accomplished exactly what the casino achieved by diversifying risk.n
Variance of a portfolio = 
n
 ωiωjσiσjρi,j
i=1 j=1
where ␻i is the percentage weight of asset i, ␻j is the percentage weight of asset j,␴i is the standard deviation of asset i, ␴j is the standard deviation of asset j, and␳i,j is the correlation between returns of asset i and asset jThe primary driver of diversification is the correlation among assets. Ifeveryone in a casino wins when I win at the blackjack table, then the casino is infor a very long night. However, if my performance is completely independent ofall other bettors’ performance, then diversification is at its best.Figure 5.3 illustrates the effectiveness of diversification. We analyze a portfolio containing anywhere from one to 1000 stocks, each with an annualized standard deviation of 20 percent. The correlation among all stocks in the portfolioranges from 0.00 to 1.00.Number ofstocks
Correlation among stocks1.000.75 0.50 0.250.00
1510
20%20%20%
20%18%18%
20%15%15%
20%13%11%
20%9%6%
50100
20%20%
17%17%
14%14%
10%10%
3%2%
5001000
20%20%
17%17%
14%14%
10%10%
1%1%
FIGURE
5.3
Volatility of a Portfolio. As the number of stocks within a portfolio increase, the volatility of the portfoliodecreases. As the correlation decreases among stocks, the volatility of the portfolio also decreases.
As we see, when correlation among stocks is 0.25 or lower, adding as few as10 stocks can reduce overall portfolio volatility dramatically. However, with correlations of 0.75 and higher, the so-called benefits of diversification are muted.
PART 1 Structural Foundations for Improving Technical Trading
104
The remainder of this chapter will focus on combining uncorrelated trading strategies with positive expected returns within a portfolio to minimize risk.
THE BEST DIVERSIFICATION: ACROSS MARKETSThe same logic and mathematics that Harry Markowitz applied to stocks can alsobe applied to quantitative strategies in the stock and futures markets. In a basicexample, we will look at the performance of a moving average crossover strategywhen tested on nine futures markets. Markets tested include Japanese yen, Swissfranc, eurodollars, T-bonds, crude oil, corn, cotton, coffee, and sugar. Buy signalsare generated when today’s 10-day simple moving average is greater than today’s40-day simple moving average. Shorts are entered when today’s 10-day simplemoving average is less than today’s 40-day simple moving average. Figure 5.4depicts both the individual market and portfolio performance statistics.The portfolio produces reward-to-risk performance statistics superior to anyof the individual markets. The K-ratio of the portfolio’s equity curve (0.31) isgreater than the K-ratio of all but one market (Japanese yen). The Sharpe ratio ofthe portfolio’s equity curve (1.30) is greater than the Sharpe ratio of any singlemarket contained in the portfolio.These performance numbers show that even if we knew in advance whichmarket would perform the best, we would still prefer to trade the portfolio over anysingle market since our risk-to-reward statistics are maximized by utilizing thebenefits of diversification. The portfolio’s results are achieved without any foresight as to which markets will perform best in the future. And as appealing as this
Market
Net Profit
K-ratio
Sharpe Ratio
JYSFED
$1,582,763$673,875$2,865,075
0.520.130.17
0.770.351.00
USCLC
$619,531$968,880$741,025
0.120.100.16
0.300.420.30
$629,190$1,033,564$360,606$1,052,723$9,474,509
0.060.150.040.160.31
0.300.340.190.441.30
CTKCSBAveragePortfolio
FIGURE
5.4
Performance of Varying Markets. The performance of the portfolio exceeds the performance of any individual markets.
CHAPTER 5 Performance of Portfolios
Correlation
JY
105
SF
ED
US
CL
JY
1.00
SF
0.14
1.00
EDUS
⫺0.01⫺0.13
0.130.11
1.000.22
1.00
0.12 ⫺0.06
⫺0.25
⫺0.03
1.00
CL
C
CT
KC
C
⫺0.07
0.00
⫺0.06
0.09
0.06
1.00
CTKC
0.070.05
0.010.12
0.11⫺0.03
⫺0.10⫺0.04
0.040.21
0.03⫺0.03
1.000.05
1.00
SB
⫺0.14 ⫺0.03
0.07
⫺0.03
0.01
⫺0.06
⫺0.13
⫺0.08
FIGURE
5.5
SB
1.00
Correlation of Selected Market Returns. Because the correlation of returns of many markets is near zero,benefits of diversification decrease return while maintaining returns.
approach is in this example, adding more uncorrelated markets could reduce riskfurther. The average correlation of monthly returns within the nine markets is lessthan +0.01, which suggests that the portfolio is realizing tremendous benefits ofdiversification.Figure 5.5, above, shows a correlation matrix of monthly returns generatedby the channel breakout strategy. While returns among markets within the samesector can be highly correlated, returns among markets within different sectorsgenerally have small or no correlation. It is these noncorrelated returns that provide the risk-reducing diversification that our portfolio needs.
BETTER DIVERSIFICATION: ACROSS UNCORRELATED STRATEGIESIn an ideal world, we should trade our strategies on as many markets as possible toreduce the strategy’s risk within a portfolio. By adding more markets—assuming eachmarket added possesses similar expected edge—we reduce risk while maintainingexpected returns. But why stop with adding markets to the portfolio for diversification? We can expand the diversification by adding other uncorrelated return streamsto the portfolio. Instead of trading only one strategy, the next logical step is to trademultiple strategies on multiple markets. It is entirely possible to create two or moreprofitable strategies that are not correlated. One strategy might follow major markettrends, while another may generate trading signals based on a particular price pattern.To see if combining strategies improves our reward-to-risk characteristics,we will trade another strategy in addition to the 10-day/40-day moving averagecrossover on our nine-market portfolio. We combine the performance of our moving average crossover strategy with the performance generated by a 40-day
PART 1 Structural Foundations for Improving Technical Trading
106
Moving Average CrossoverK-ratio0.31Sharpe Ratio1.30Channel BreakoutK-ratioSharpe Ratio
0.411.22
Combined Crossover and BreakoutK-ratioSharpe RatioFIGURE
0.361.315.6
Performance of Varying Strategies. Trading multiple strategies helps our portfolio’s reward to risk statistics.
entry/20-day exit channel breakout strategy. Figure 5.6 details the K-ratio andSharpe ratio of each strategy on its own and then a combination of the two strategies into a new multistrategy portfolio.We see that combining the moving average crossover with the channel breakout does not improve performance. Unlike the diversification of markets exampleabove, where adding multiple markets produced a portfolio that was better than theperformance of any single market, the combination of these two trend-followingstrategies does not lead to an improved trading program.There are two reasons for this lack of improvement in performance. First, weare only combining two strategies. As more strategies are included in our tradingprogram, we will pick up additional diversification. Second, and more important, themoving average crossover and channel breakout strategies are highly correlated. Thecorrelation of monthly returns is +0.85. Remember, diversification only helps whencombining noncorrelated returns. In this case, the high correlation of returnsbetween the two strategies helps explain why the combination of the two did not produce better results. We will need to focus our attention on developing strategies withmuch lower correlation to each other.By trading multiple strategies on multiple markets, we harness the power ofdiversification. Many professional money managers will trade as many as 10 to 15uncorrelated strategies within their organization, all in order to smooth profits andreduce risk from their performance.
GOOD DIVERSIFICATION: ACROSS PARAMETERS WITHIN STRATEGIESWhy stop at adding multiple strategies to our portfolio when we can trade multiple parameter values for each strategy? In the channel breakout example above, weenter on 40-day highs and lows and exit on 20-day highs and lows. Instead of trading the 40- and 20-day parameters, we could add two additional parameter sets: a20-day entry with a 10-day exit and an 80-day entry with a 40-day exit. If each
CHAPTER 5 Performance of Portfolios
107
strategy is equally profitable and the returns have zero correlation with each other,then we can retain our expected return and lower our risk by combining the fourparameter sets into one trading portfolio.In reality, the profit of different parameter sets tends to be highly correlated.As a result, we do not accomplish much by spreading our system across parameter sets. We tested the three parameter sets on our nine-market portfolio, comparing reward to risk statistics for each individual test to a combined portfolio of allthree tests, and the results can be seen in Figure 5.7.Much like the combination of the channel breakout and moving averagecrossover strategies, the combination of three parameter sets of a channel breakout strategy did not enhance the reward-to-risk statistics. Again, this occurs due tothe highly correlated nature of using varying parameters within the same strategy.Because the actual entries and exits for a 20-day entry/10-day exit channel breakout strategy are similar to an 80-day entry/40-day exit strategy, the profit and lossnumbers are highly correlated. The correlation of monthly returns from these threeparameter sets range from +0.63 to +0.88, which is too high to realize any significant benefits of diversification.
THE TRADER’S HOLY GRAILTraders are fond of speaking of the “Holy Grail.” In the world of quantitative trading, the Holy Grail is a magic potion of trading performance whose returns areperfectly consistent and never lose money.Personally, I do not think the Holy Grail trading strategy exists. My half-lifetheory postulates that performance will decay over time to zero profitability.
20 day entry/10 day exitK-ratio0.35Sharpe Ratio40-day entry/20-day exit
0.85
K-ratio0.41Sharpe Ratio1.2280-day entry/40-day exitK-ratio0.41Sharpe RatioCombined threeK-ratioSharpe Ratio
FIGURE
1.420.411.28
5.7
Performance of Varying Parameters. Trading multiple parameter sets slightly helps our portfolio’s rewardto- risk statistics.
108
PART 1 Structural Foundations for Improving Technical Trading
However, though there may be no Holy Grail trading strategy, the benefits ofdiversification are one type of Holy Grail that quantitative traders can enjoy. Theability to diversify across markets, strategies, and parameters improves reward-torisk measures and may be a trader’s only free lunch. Diversification is based onmathematical principles—its advantages are not subject to debate.
CHAPTER
6
Optimizing Parameters andFiltering Trading SignalsImproving the Basic Strategy
Optimization is one of the most controversial and discussed topics in quantitativetrading. For some traders, optimization allows fine-tuning of a strategy to a market’s ebb and flow. For others, optimization is the root of most problems in tradingstrategy performance. The latter believe that scrupulously fitting strategies to pastdata yields unrealistic expectations when real-time trading begins. Which side iscorrect? In this chapter we’ll analyze the benefits and drawbacks of optimizationusing real-world results.
OPTIMIZING TRADING SIGNALS TO ENHANCE PROFITABILITYOnce we have identified a profitable trading system, we may wish to tweak itsparameters. Parameters are any alterable inputs that are found in a trading system,such as the length of a moving average, the multiplier in a volatility breakout, or thelook-back period for oscillators.For example, if we buy at a 40-day channel breakout high only when a 10-daymoving average is greater than a 40-day moving average, we have a trading systemwith three parameters: the number of days in the channel breakout (40 days), thelength of the short moving average (10 days), and the length of the longer termmoving average (40 days). If we filter these trades by only trading when a 14-dayADX is greater than 20, then we add two additional parameters: the length of theADX (14 days) and the trigger to take positions (20 in the ADX). We already have109
Copyright 2003 by Lars Kestner. Click Here for Terms of Use.
110
PART 1 Structural Foundations for Improving Technical Trading
five parameters in our system and we have yet to add an exit strategy. If we takethe parameterization even further, we could use five values for short entries, whichare different than long entries. You can see how a simple system can become verycomplex by adding just a few rules.Some traders might test their trading strategy over a wide range of values foreach parameter. This process is generally referred to as optimization. If we’re trading a channel breakout where we enter on an x day highs and lows and exit ony day highs and lows, for instance, we could optimize the values of x and y. To doso, we could vary x from 11 to 80 in increments of one, and y from 11 to 30,recording the performance of each combination. This testing would lead to 1400individual tests: 70 different x’s and 20 different y’s.With the increased speed of personal computing, 1400 tests is certainly possible in one night’s computing time. But if we optimize after adding another layerof complexity to our strategy, the process quickly becomes out of control. Whenwe amend the strategy to only take our channel breakout trades when an a dayADX is greater than b, the total number of trials balloons to 560,000 if we run abetween 11 and 30, and b from 21 to 40. This is a stretch for even today’s fastestcomputers.One method of simplification is to vary each parameter by more than oneunit per test. If we increase each of the four parameters in increments of fiveinstead of one, we reduce the total number of tests from 560,000 to 1875.Although this is manageable with today’s computing power, what do we do withthe results when we finish?Optimization vs. Curve FittingConventional wisdom is that optimization is an important technique to maximizethe expected value of trading strategies. Popular thinking says parameter valuesthat have performed best in the past are most likely to do so in the future. Whetheror not this statement is true, if optimization is taken too far, the process turns intocurve fitting of data.Consider our optimization above with 560,000 trials. Suppose the parameterset of entering on 54-day highs and lows, exiting on 24-day highs and lows, whileonly taking trades when the 19-day ADX is greater than 18 (x = 54, y = 24, a =19, and b = 18) is the best performing combination and produces a Sharpe ratio of5.0. Meanwhile, the average Sharpe ratio for all 560,000 trials is 1.5.Can we expect this specific set of parameters to perform three times as wellas the average parameter set in the future? Chances are that it won’t and the performance of any particular performance set will revert to the mean in the future.Of all the trials, approximately half will perform better than average and half willperform worse. A few of the 560,000 trials will produce spectacular winners, whilea few will produce unbelievable losers. The distribution of the Sharpe ratios across
CHAPTER 6 Optimizing Parameters and Filtering Trading Signals
111
all parameter sets might look similar to a bell curve normal distribution (seeFigure 6.1). To a large degree, the dispersion of varying profits and losses is dueto chance.If the set of parameters (x = 54, y = 24, a = 19, and b = 18) created the bestperformance of the 560,000 sets, chances are much of the past performance wasdue to luck and performance will likely be much worse in the future. This is not tosay the overall strategy will be unprofitable; rather, that blindly picking parametersets based on past performance alone will usually overestimate true performance.Let me give you an example of why optimization is misunderstood. Startwith 100 coins and distribute one coin to 100 separate people. Have each person flip their coin five times and mark the number of times the coin comes upheads. Due to random chance, it’s likely that at least one person will flip fiveheads in a row. Behold, that person has found a magic coin! Right? No. He justgot lucky.The same mistake can be made in optimization of trading systems. Traderswill often perform complex trading simulations and pick the best performingparameter set without looking at other factors. That same trader will usually betremendously disappointed when performance in real-time trading is not as profitable as the simulation. The trader will use idioms to explain the trading failure,such as “the market changed and my system fell apart.” This is not why the trader
Theoretical Distribution of Sharpe Ratios9%8%
Occurrence
7%6%5%4%3%2%
5.2
4.8
4.4
4.0
3.6
3.2
2.8
2.4
2.0
1.6
1.2
0.8
0.4
0.0
–0.4
–0.8
–1.2
–2.0
0%
–1.6
1%
Sharpe Ratio
FIGURE
6.1
Theoretical Distribution of Sharpe Ratios. If we test 1000 parameter sets, the distribution of their performance ratios will likely fall under a normal distribution.
PART 1 Structural Foundations for Improving Technical Trading
112
failed. The market did not change; rather, the performance of the trader’s strategyreverted to results of the average overall parameter sets.Measuring the Value of OptimizationAt this point, some readers might be upset that I’m throwing cold water on theconcept of optimization. Although I am not convinced that optimization is particularly useful, I can test its value through research.Using the channel breakout, we will simulate trading on our stable of futuresmarkets and stocks between the years 1990 and 2001. We test eight parameter setsby varying our channel breakout entry from 10 to 80 days in increments of 10. Ourexit will always be half the length of the entry. At the end of each year, we’ll rankthe parameter sets by annual net profit. Over time, we’ll compare the rank of oneyear’s performance to the next. For example, if a 40-day entry channel breakoutwas the third best performing parameter in 1990 and the eighth best in 1991, wecould plot the coordinate (3, 8) in a scatterplot like those in Figures 6.2a and 6.2b.Once the ranks of all combinations of parameters for all years are added to thegraphs, we can determine if a relationship exists between successful performingparameters of one year compared to the performance the following year.The results show a bias for parameters to be strong from one year to the next.Note that a best-fit trendline slopes upward, suggesting that the best ranking param-
Optimization Results of Futures Markets109
Rank of This Year
876543y = 0.6628x + 1.4753R2 = 0.4393
2100
2
4
6
8
10
Rank of Previous Year
FIGURE
6.2a
Optimization Results of Futures Markets. The rank of one year’s net profit plotted against the rank of thenext year’s net profit for all eight parameter sets.
CHAPTER 6 Optimizing Parameters and Filtering Trading Signals
113
Optimization Results of Stocks109
Rank of This Year
876543y = 0.7238x + 1.2429R2 = 0.5239
2100
2
4
6
8
10
Rank of Previous Year
FIGURE
6.2b
Optimization Results of Stocks. The rank of one year’s net profit plotted against the rank of next year’snet profit for all eight parameter sets.
eters in one year are likely to be the best performing parameters during the next year.This phenomenon exists for the channel breakout when tested on both futures markets and individual stocks. The results above indicate that we want to stick with thebest performing parameters and that performance from year to year is not random.At the same time, other properties could be at work. In the test above, wegather performance data from eight variations of a channel breakout strategy. Thiscould be explained by the fact that some parameters performed consistently betterthan others over the life of the test.In the graphs in Figures 6.3a and 6.3b, we add a twist to our annual rankings.Instead of ranking net profit generated from one year’s performance versus theprevious year’s performance, we normalized each year’s profit versus the averageover the life of the test. If the 10-day entry/5-day exit channel breakout averageda profit of $100,000 over the 12 years of the test, then we subtract $100,000 fromeach year’s profit to normalize the profit numbers over all parameter sets.This normalization process will allow us to ask a different optimizationquestion. After creating new scatterplots, we will be able to determine if thisyear’s performance is above or below average, and what it might mean for nextyear’s performance.For the futures markets in Figure 6.3a, there does appear to be a slight bias indeviations of performance from year to year. The positive sloping trendline suggests
PART 1 Structural Foundations for Improving Technical Trading
114
that if this year’s performance for any parameter set is above average, then next year’sperformance is also likely to be above average. While the slope and correlation ofthe best fit trendline is small, it’s significant in a statistical sense. The results of thefutures market performance data suggest that optimization of parameters from oneyear to the next will improve performance.While the futures market performance gives credence to the notion of optimization, the stock performance data in Figure 6.3b does not. The slope of thetrendline for stock performance ranks from one year to the next is slightly negative, indicating that a parameter that produced higher than average profits this yearis likely to produce slightly less than average profits the following year. The correlation is small enough to suggest that no relationship—positive or negative—exists between this year’s performance when compared to average performanceand next year’s performance.While the above results are aggregated over an entire portfolio of markets,we can perform similar analysis on a single market. In this case, we chooseGeneral Electric to test for the value of optimization (Figures 6.4a and 6.4b).Interestingly, we do not see the same results as for a portfolio of markets.When profit is ranked and one year’s rank is plotted against the next, we see little relationship. The slope is slightly positive, but nowhere near the levels seen
Optimization Results of Futures Markets Compared to Mean109
Rank of This Year
8765432y = 0.2913x + 3.1004R2 = 0.0857
100
2
4
6
8
10
Rank of Previous Year
FIGURE
6.3a
Optimization Results of Futures Markets Compared to Mean. The normalized rank of one year’s net profitplotted against the normalized rank of next year’s net profit for all eight parameter sets. Ranks are normalized by subtracting the average annual profit for a parameter set from the annual return.
CHAPTER 6 Optimizing Parameters and Filtering Trading Signals
115
Optimization Results of Stocks Compared to Mean10y = –0.0143x + 4.5643R2 = 0.0002
9
Rank of This Year
8765432100
2
4
6
8
10
Rank of Previous YearFIGURE
6.3b
Optimization Results of Stocks Compared to Mean. The