Skip to content

Robust Parameter Optimization for Pairs and ETFs: The Quick and Dirty Method

September 4, 2009

Following up on a good post by BZB http://bzbtrader.blogspot.com/2009/09/get-pair.html who is a full-time expert trader, I decided that I would like to provide some input on how to figure out what parameters to use following optimization. Again I do endorse that anyone who wishes to trade pairs is probably better off using ETF Rewind’s http://etfrewind.blogspot.com/pair application which has almost anything a hardcore quant could ever want than developing your own system. The application uses the z-score which is essentially an offshoot of using bollinger bands with a mean and standard deviation. I use it myself as a nice complement to my internal  differential DV2 pairs application because it has an imperfect correlation and allows me to find the best parameter length for a given pair. The application can also be used to develop systems for trading individual stocks or ETFs.

Optimization is a valuable tool if used properly. There are a few important points that I would emphasize are critical for avoiding unpredictable or disastrous results:

1) the pair must make logical sense: I rarely trade pairs that do not have a conceptual relationship– generally I stick to stocks or ETFs in the same sector, commodity, or country. An example would be to trade Vanguard Financial Sector vs iShares Financials.  I also heavily trade leveraged ETF arbitrage which is the underlying ETF such as SPY vs its leveraged counterpart SSO or SDS. The odd time I stray from this is when a cross-pair that has some relationship seems to offer superior risk/return characteristics than trading the individual components themselves AND it compensates me by offering a much higher return than traditional pairs. A good example would be XHB vs IYR (the homebuilders vs the real estate sector).

2) the parameter that best works for one logical pair should work for related pairs:  it doesn’t make sense to use the results of optimization for say the leveraged ETF pair SPY vs SSO if it does not work for QQQQ vs QLD for example. The same applies to stock pairs: if you find the optimal parameter for say United States Steel vs AK Steel and it does not yield profitable results for Mittal Steel vs United States steel then you are using an overfitted parameter. The same applies to trading stocks individually–the DV2 and RSI2 are currently robust because they work across most stocks– using the z-score is no different, it is simply a different mean-reversion indicator.

In theory, the ideal way to achieve robustness is to simply choose the top quantile or decile of parameter settings using linearity times return, and invest a part of your portfolio in each individual parameter setting within this quantile or decile cell. Obviously this is only practical if you have a lot of money. This is likely what top hedge funds are doing–diversifying by parameter setting to avoid sudden shocks. For the average trader, you can achieve this by diversifying across the top 2 or 3 parameters. If you want to simplify your life,here is the Quick and Dirty Method to find robust parameters:

1) Optimize on linearity x return for better results

2) find the optimal parameters for at least 20 different related pair combinations (these can be overlapping using one side with other partners) , make sure to optimize using the 2-months out of sample feature. Remember this is  either stocks in the same sector or leveraged ETFs vs underlying or sector ETFs from different providers. It could also be sector vs sector –so XLF vs XLE etc. Note:  you can do this process differently by inputting say 5-10 different stocks in the same industry in the “Matrix” tab on ETF Rewind and test all the combinations (more than 20) simultaneously using one parameter such as a 15 day mean with 1 standard deviation for entries. You can simply start with say 2 or 3 as the mean and work your way up, selecting the parameter combination that is profitable on the highest # of combinations. You could calculate this as a % by dividing the number of profitable cells by the total # of cells in the matrix. In this case if you wanted to dig deeper you could calculate the average return and standard devation for the entire matrix for a given parameter choice and choose the parameter combination that has the highest sharpe ratio.

3) take the average or median setting  for both length of mean and z-score entry/exit as the parameter to be used for all pair trades in that sector. Record the standard deviation for both the length of mean and z-score entry/exit.

4) combine the average or median setting with the optimal setting to yield your final robust parameter setting

5) calculate the performance out of sample over 3 months for short-term pair trades (lookback period length less than 10 with z-score entry/exit less than 1) and 12 months for long-term pair trades (lookback period length greater than 10 with z-score entry/exit greater than 1) using the robust parameter setting and the average/median setting. If you find that the average/median setting +/- 2 standard deviations using parameters  was not profitable, then you probably have an unstable pair and it should be set aside. If your results are unprofitable but there were profitable settings within the +/-2 standard deviations around the average/median parameter setting, then you need to diversify across more than one setting.

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: