75391,766.75480,204.31503,163.31
3,506.5323,663.6415,548.2649,958.26147,307.00189,659.00
–182,745.02–164,399.25–110,399.25–118,052.91–78,263.91–28,682.42
43,157.5363,036.53–20,793.97–50,101.49–111,774.35–66,350.87
Cum Profit
3:14 PM
11/4/199911/26/199912/1/199912/22/19991/4/20001/6/2000
5/13/19995/26/19996/17/19997/21/19998/16/19999/24/1999
Entry Date
12/30/03
13,28710,02510,8009,4498,84210,181
17,12619,87918,62915,92815,65314,063
Shares
Unilateral Pairs Trading (QQQ/SPY)
ShortLongShortLongShortLong
Position
TABLE 2.3
4199_P-02.qxdPage 35
35
QQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQ
LongShortLongShortShortShort
LongShortLongLongShortShort
LongLongLongShortLongLong
Symbol
71,44891,63794,66392,50076,65879,371
8/20/20019/19/20019/27/200110/11/200111/21/200111/29/2001
4/4/20014/12/20015/31/20016/15/20017/2/20018/2/200137.8530.6428.433.1938.4739.03
34.7140.344.5441.845.6543.798/27/20019/25/200110/4/200110/30/200111/27/200112/5/2001
4/6/20014/27/20016/6/20016/22/20017/6/20018/9/2001
1/4/20011/26/20012/27/20013/12/20013/21/20013/29/2001
9/20/200010/16/200010/26/200011/16/200012/4/200012/15/2000
Exit Date
39.2829.7131.6533.7140.0541.2
36.945.1548.0843.6243.0140.41
61.6363.5651.544440.5239.38
93.3781.1278.1975.3764.1264.25
ExitPrice
3.78–3.0411.44–1.574.115.56
6.31–12.037.954.355.787.72
18.09–1.29–11.5212.76.729.58
–0.14–2.857.470.833.848.98
% Change
102,170.66–85,222.44307,654.75–48,100.04121,119.48172,235.23
142,750.92–283,293.47169,367.8098,500.20137,499.28196,901.97
297,246.81–25,698.10–221,497.06224,166.45131,166.31201,469.30
–2,000.14–40,405.21102,941.3012,166.3156,370.52139,067.81
Net Profit
5451334
2104535
1911314
684527
BarsHeld
1,942,054.751,856,832.252,164,487.002,116,387.002,237,506.502,409,741.75
1,520,908.381,237,614.881,406,982.631,505,482.881,642,982.131,839,884.13
1,068,550.751,042,852.63821,355.561,045,522.001,176,688.251,378,157.50
501,163.19460,757.97563,699.25575,865.56632,236.06771,303.88
Cum Profit
36
65,18358,41147,84454,12152,08358,255
52.1962.7558.2550.443.4443.55
93.583.584.574.7561.7570.59
EntryPrice
3:14 PM
1/3/20011/12/20012/9/20013/7/20013/20/20013/23/2001
9/12/200010/4/200010/20/200011/9/200011/30/200012/6/2000
Entry Date
12/30/03
31,48831,72633,01035,02644,92048,314
15,38616,97716,31419,62323,78521,935
Shares
Continued
LongLongShortLongLongShort
Position
TABLE 2.3
4199_P-02.qxdPage 36
TRADE LIKE A HEDGE FUND
QQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQ
ShortLongLongLongLongShort
LongLongShortLongLongShort
LongShortShortShortShortLong
LongShortShortShortLongLong
192,191183,957198,674199,636196,477184,017
12/5/20021/7/20032/19/20033/14/20034/1/20035/20/2003
8/2/20028/22/20029/26/200210/11/200211/5/200211/12/200226.9526.4125.225.7325.4427.76
22.7825.7422.1621.5525.7124.4
35.330.4732.0828.3626.3626.2
42.739.4237.6535.4633.6136.93
12/24/20021/21/20032/26/20033/20/20034/17/20035/28/2003
8/15/20028/28/20029/27/200210/30/200211/8/200211/15/2002
4/16/20025/9/20025/28/20026/18/20026/25/20027/26/2002
12/10/20011/4/20021/25/20022/14/20022/27/20023/20/2002
25.525.4124.6826.5426.1629.16
24.2424.0221.5524.0625.4925.9
34.4331.5731.4728.3126.5822.56
41.3241.9538.4737.1535.3936.87
–5.383.792.06–3.152.835.04
6.416.682.75–11.650.866.15
–2.463.611.9–0.180.8313.89
3.236.422.184.775.30.16
–278,677.09183,957.00103,310.57–161,705.44141,463.31257,623.73
299,212.22330,141.84146,605.72–642,437.0640,645.75297,639.00
–98,711.82140,163.1675,304.81–7,230.3733,967.89569,037.75
104,321.18217,737.0877,728.59173,804.92201,187.926,420.51
13954125
9411333
9486214
2824311
4,096,604.004,280,561.004,383,871.504,222,166.004,363,629.504,621,253.00
4,202,686.004,532,828.004,679,433.504,036,996.504,077,642.254,375,281.00
3,092,230.253,232,393.503,307,698.253,300,468.003,334,436.003,903,473.75
2,514,063.002,731,800.002,809,528.502,983,333.503,184,521.503,190,942.00
3:14 PM
204,940191,943240,337255,951184,754198,426
4/3/20025/3/20025/15/20026/10/20026/21/20027/8/2002
12/6/200112/21/20011/23/20022/8/20022/22/20023/5/2002
12/30/03
113,462127,421123,450144,604154,400156,329
75,59586,06294,791102,843113,027107,006
4199_P-02.qxdPage 37
How to Play the QQQ-SPY Spread Using Unilateral Pairs Trading
37
4199_P-02.qxd
12/30/03
3:14 PM
Page 38
38
TRADE LIKE A HEDGE FUND
SMH and QQQ, 3/5/02This system will work on any two assets that are highly correlated whereone asset is more volatile than the other. For instance, SMH, which isthe ETF tracking the semiconductor sector, is correlated with QQQ (allof the components of SMH are also components of QQQ) and has beenmore volatile since its inception on June 5, 2000. Using QQQ as the othermember of the pair but trading SMH according to the rules previously described would have the results shown in Table 2.4.The market in general had been selling off pretty harshly in the latterhalf of February 2002, the chip stocks most of all. After the Nasdaq hadfailed to hold onto the 2000 level in January and with “Enron-itis” startingto creep into the market in the various incarnations of TYC and WCOM, investors got cold feet and decided to bail. SMH had several 2 percent downdays in a row before getting out of whack with its QQQ counterpart, triggering a buy signal on the morning of March 1 at 40.77. The market as awhole rebounded the first week of March, with the chip stocks leading thepack. The spread between SMH and QQQ got back down to normal levels(i.e., less than 0.5 standard deviations away from the average spread) onMarch 5 when the system sold at 46.85 for a 14.91 percent profit (Figure2.6).
TABLE 2.4
ResultsAll Trades
LongTrades
ShortTrades
Buy &Hold
All TradesAverage Profit/Loss %Average Bars Held
383.90%6.74
192.24%6.21
195.56%7.26
1–71.22%767
Winning TradesAverage Profit %Average Bars HeldMaximum ConsecutiveWinning Trades
26 (68.42%)7.44%5.62
11 (57.89%)6.47%4.27
15 (78.95%)8.15%6.6
00.00%0
6
3
6
0
Losing TradesAverage Loss %Average Bars HeldMaximum ConsecutiveLosing Trades
12 (31.58%)–3.76%9.17
8 (42.11%)–3.56%8.88
4 (21.05%)–4.16%9.75
1–71.22%767
2
2
1
1
4199_P-02.qxd
12/30/03
3:14 PM
Page 39
How to Play the QQQ-SPY Spread Using Unilateral Pairs Trading
no of standard deviations
39
1.501.000.500.000.01–0.50–1.00–1.50–2.00
Ratio SMH/QQQ and its 20 Period Moving Average
1.30
1.291.27
1.251.201.1550.0049.0048.0047.0046.00
45.3045.0044.0043.0042.0041.0040.00
FIGURE 2.6
SMH and QQQ on March 5, 2002.
4199_P-02.qxd
12/30/03
3:14 PM
Page 40
40
TRADE LIKE A HEDGE FUND
KLAC, 4/10/01This technique can also be used to play the spread between stocks andtheir peers. For instance, KLAC and NVLS are the two top components ofthe Philadelphia Semiconductor Index (the “SOX”), making up 12 percentand 9 percent of the index, respectively. Viewing KLAC and NVLS as a pairbut trading KLAC according to the rules previously specified has the resultsshown in Table 2.5.TABLE 2.5
ResultsAll Trades
Long Trades
Short Trades
All TradesAverage Profit/Loss %Average Bars Held
572.84%6.47
255.99%7.04
320.37%6.03
Winning TradesGross ProfitAverage Bars HeldMaximum ConsecutiveWinning Trades
33 (57.89%)$325,058.035.52
16 (64.00%)$194,534.896.44
17 (53.13%)$130,523.164.65
10
8
5
Losing TradesAverage Loss %Average Bars HeldMaximum ConsecutiveLosing Trades
24 (42.11%)–6.75%7.79
9 (36.00%)–4.96%8.11
15 (46.88%)–7.82%7.6
6
2
5
In the week prior to April 10, 2001, KLAC fell over 25 percent and NVLS(shown in the third panel of Figure 2.7) fell about 20%. Consequently, theaverage spread between these two highly correlated stocks fell about 2standard deviations from its norm. Meanwhile, KLAC had a greater than2 percent down day on April 9, so all of the conditions were in place. Buying KLAC on April 10 at 34.45 and holding until the standard deviation of thespread fell back below 0.5 standard deviations would have resulted in aprofit of 54.28 percent when the system sold on April 20 at 53.15.
ALTR, 7/17/2000Seminconductor equipment makers ALTR and XLNX make another goodpair of highly correlated stocks, with ALTR being the more volatile of thetwo. In fact, no other components of the Nasdaq 100 are as highly correlated. Using these two as the pair and ALTR as the trading vehicle we getthe result shown in Table 2.6 (see page 42).
4199_P-02.qxd
12/30/03
3:14 PM
Page 41
How to Play the QQQ-SPY Spread Using Unilateral Pairs Trading
41
1.501.00
no of standard deviations
0.500.34
0.00–0.50–1.00–1.50–2.00
Ratio KLAC/NVLS and its 20 Period Moving Average
1.041.001.000.950.90
58.09
NVLS
55.0050.0045.0040.0035.00
60.5960.0058.0056.0054.0052.0050.0048.0046.0044.0042.0040.0038.0036.0034.0032.00
FIGURE 2.7
KLAC on April 10, 2001.
4199_P-02.qxd
12/30/03
3:14 PM
Page 42
42
TABLE 2.6
TRADE LIKE A HEDGE FUND
ResultsAll Trades
Long Trades
Short Trades
All TradesAverage Profit/Loss %Average Bars Held
564.09%7.3
305.06%6.4
262.97%8.35
Winning TradesAverage Profit %Average Bars HeldMaximum ConsecutiveWinning Trades
39 (69.64%)9.88%7.44
21 (70.00%)10.41%6.86
18 (69.23%)9.26%8.11
6
5
7
Losing TradesAverage Loss %Average Bars HeldMaximum ConsecutiveLosing Trades
17 (30.36%)–9.18%7
9 (30.00%)–7.41%5.33
8 (30.77%)–11.17%8.88
3
1
3
In the week before July 17, 2000, ALTR went up over 20 percent, withXLNX only following about 12 percent. Consequently the ratio between thetwo assets was about 2 standard deviations higher than the moving averageof the ratio. After ALTR then had a big up day (but down open to close, interestingly), the system shorted ALTR at the open the next day at 59.22. Theratio did not get back to historic norms for eight days, finally settling downon July 27, when the system covered ALTR at 48.47 for an 18.15 percentprofit. (See Figure 2.8.)
CONCLUSIONWith more than 10,000 stocks and many other asset classes—commodities,foreign stocks, indices, bonds, and so on—there are more than enough opportunities to find highly correlated pairs and map out the spreads betweenthose pairs. Many books have been written about common arbitrage andpairs trading techniques. Books on merger arbitrage, relative value arbitrage, capital structure arbitrage, and convertible arbitrage are lining theshelves of your local bookstore. However, my personal feeling is that all ofthese strategies are too crowded and it is getting harder to make money onthe small spreads that the strategies covered in these books try to exploit.By mapping out the correlations between very liquid and highly correlated instruments such as QQQ and SPY, SMH and QQQ, KLAC and NVLS,and so on, you can find opportunities that will arise in the spreads betweenthese assets, regardless of market direction.
4199_P-02.qxd
12/30/03
3:15 PM
Page 43
How to Play the QQQ-SPY Spread Using Unilateral Pairs Trading
43
no of standard deviations2.001.501.000.500.00–0.42–0.50–1.00
Ratio ALTR/XLNX and its 20 Period Moving Average
0.700.680.67
0.650.650.630.6095.00
XLNX
90.0085.0080.00
77.31
75.0070.0062.0060.0058.0056.0054.00
52.0051.7850.0048.0046.0044.00
FIGURE 2.8
ALTR on July 17, 2000.
4199_P-02.qxd
12/30/03
3:15 PM
Page 44
44
TRADE LIKE A HEDGE FUND
APPENDIXUnilateral Pairs Trading CodeVAR Close1, Close2, RatioPane, StDevPane, TextPane, Bar, Sym, ActualRatioSeries,ActualRatioSMASeries, DeltaSeries, DeltaSMASeries,DeltaDifferenceSeries, DeltaNormSeries, MAPeriod: Integer;VAR Up_Threshold, Down_Threshold, Exit_Up_Threshold, Exit_Down_Threshold,R, Value, atr1, atr2: float;VAR Stock1, Stock2, LongSymbol, ShortSymbol, CurrentSymbol, TestSymbol: STRING;// assigning values to variablesUp_Threshold := 1.5;Down_Threshold := -1.5;Exit_Up_Threshold := 0.5; // positions entered above Up_Threshold are exited hereExit_Down_Threshold := -0.5; // positions entered below Down_Threshold are exitedhere//MAPeriod := #OptVar3;MAPeriod := 20;// If you want to enter your symbols manually, comment the code between the ****// out and enter your stocks in the lines between the ####, then click on one of// the stocks of the chosen pair in your watchlist// ****************************************************************************// This loop makes sure all series are synchronizedFOR SYM := 0 TO WatchListCount - 1 DOSetPrimarySeries( WatchListSymbol( SYM));// end of synch loop// find the best correlated symbolR := 0.0;LongSymbol := ‘’;Value := -1.0;CurrentSymbol := GetSymbol;FOR SYM := 0 TO WatchListCount - 1 DOBEGINTestSymbol := WatchListSymbol( SYM);SetPrimarySeries(TestSymbol);Close1 := #Close;RestorePrimarySeries;R := Correlation( Close1, #Close, 0, BarCount - 1);Print(TestSymbol + ‘ ‘ + FormatFloat(‘#.####’, R));IF (R > Value) AND (TestSymbol <> GetSymbol) THENBEGINCurrentSymbol := TestSymbol;Value := R;
4199_P-02.qxd
12/30/03
3:15 PM
Page 45
How to Play the QQQ-SPY Spread Using Unilateral Pairs Trading
45
END;END;// end of “find the best correlated symbol” code// ****************************************************************************// ############################################################################Stock1 := GetSymbol; // the symbol of the Price Series that is currently beingoperated onStock2 := CurrentSymbol; // the symbol with the best correlation// ############################################################################// compute seriesSetPrimarySeries( Stock1);Close1 := #Close;SetPrimarySeries( Stock2);Close2 := #Close;RestorePrimarySeries;ActualRatioSeries := DivideSeries( Close1, Close2);ActualRatioSMASeries := SMASeries( ActualRatioSeries, MAPeriod);DeltaSeries := SubtractSeries( ActualRatioSeries, ActualRatioSMASeries);DeltaSMASeries := SMASeries( DeltaSeries, MAPeriod);DeltaDifferenceSeries := SubtractSeries( DeltaSeries, DeltaSMASeries);DeltaNormSeries := DivideSeries( DeltaDifferenceSeries, StdDevSeries( DeltaSeries,MAPeriod));// correlation coefficientValue := Correlation( Close1, Close2, 0, BarCount - 1);// graphicsHideVolume;EnableNotes(false);RatioPane := CreatePane( 100, True, True);PlotSeries( ActualRatioSeries, RatioPane, #Navy, #Thick);PlotSeries( ActualRatioSMASeries, RatioPane, #Blue, #Thick);DrawLabel(‘Ratio ‘ + Stock1 + ‘/’ + Stock2 + ‘ and its ‘+ IntToStr(MAPeriod) + ‘ Period Moving Average’ , RatioPane);StDevPane := CreatePane( 100, True, True);PlotSeries( DeltaNormSeries, StDevPane, #Red, #ThickHist);DrawHorzLine( Up_Threshold, StDevPane, #Black, #Thick);DrawHorzLine( Down_Threshold, StDevPane, #Black, #Thick);DrawHorzLine( Exit_Down_Threshold, StDevPane, #Blue, #Thick);DrawHorzLine( Exit_Up_Threshold, StDevPane, #Blue, #Thick);DrawLabel(‘no of standard deviations’, StDevPane);TextPane := CreatePane( 40, False, False);DrawText( ‘Correlation: ‘ + FormatFloat(‘0.####’, Value), TextPane, 10, 10, #Black,18 );// procedures
4199_P-02.qxd
12/30/03
3:15 PM
Page 46
46
TRADE LIKE A HEDGE FUND
PROCEDURE Close_Positions();BEGINif (ShortSymbol = Stock1) then LongSymbol := Stock2else LongSymbol := Stock1;SetPrimarySeries( ShortSymbol);CoverAtMarket( Bar + 1, LastPosition - 1, ‘Cover ‘ + ShortSymbol);SetPrimarySeries( LongSymbol);SellAtMarket( Bar + 1