Thursday, February 17, 2011

Learning Spread Trades

First off, I barely know what I'm doing here. I had never really thought about spread trades until I began following Michael Bigger (@biggercapital). The guy really seems to have a passion for spreads, and it's kind of contagious. Credit is also due to Aris David (@fledglingtrader) and @biggercapitalnw for posting some spread trades for me to study. Dynamic Hedge is really good with these too, so I thank him for some education too.

The spread I'm looking at is UNH - WLP.  Below is a graph of the spread. I'll explain further.


The top graph is the price of UNH 42.59 / WLP 67.21 = 0.63.
Red line = 30 day linear regression line
Blue dotted line =  2 standard deviations away from the red line
Fuchsia line = 3 standard deviations away from the red line

The bottom graph is simply the price of a dollar neutral (almost) spread: 12*UNH - 7*WLP [Long 12 shares UNH, short 7 shares WLP]. I need this bottom chart so I can analyze the actual prices of my desired spread.

Reasons for Identifying this Spread

1.  Both stocks are in the same industry
2. They are highly correlated 96.45% over the last year. Correlation  = A statistical measure of how two securities move in relation to each other.
3. They are highly co-integrated 99.50%.  Cointegration = the statistical confidence that a pair will revert to the mean. I think cointegration is the most important. High correlation means that over a given period of time, two stocks will move up or down in synchrony. But high cointegration means the two prices cannot wander too far off in opposite directions for very long before they eventually come back to a mean distance. Unfortunately, my Amibroker cannot calculate cointegration, so I rely of this nifty website Catalyst Corner. I run a trade report (see bottom of post) that confirms some of the things I'm reading on the charts.
4. It is over two standard deviations away from it's 30 day linear regression line. You can see at the beginning of 2011 the spread touched the bottom 3 STD line, then snapped back. It hit the upper range then came down to where it is today. I'm expecting similar action.
5. WLP is short term overbought in my book, RSI(2)>99.

 

Using Interactive Brokers, you can create the 12*UNH - 7*WLP spread and enter a limit order; they handle the price execution on each stock. That spread closed at 40.63 today, so I might place a limit order below that. I would be buying a price that is statistically very far from it's mean, and likely to revert back.

Exit Strategy

I'm still trying to figure this part out, but I think I'll look to exit when the spread price gets back to it's 30 day regression line, which it $53. I don't know though; I may just use discretion. I'm treating this as a short term trade, so I'd like to get out in a few days.

UNH and WLP are slow movers and I don't really expect fast action, so I think they're good to learn on. When I get more comfort with spreads, I'll look to more volatile stocks. They're not even going to make me big $$, but that's OK. If I got in at $40 and exited at $53, buying/selling $10K of each stock, it would be about $260 profit.

Difficulties I've Encountered

Finding trades on a daily basis! I wish I could just write a code in Amibroker that would scan stocks and give me the spread ideas. I can't though. I think I need to just pick a few spreads that are highly coointegrated and watch them all the time. I'd look for similar scenarios I see with UNH - WLP.

Backtesting -  I haven't figured out how to code this in Amibroker. Being a quant (albeit Simple), I feel more comfortable making trades that have some backtested results. I need to work I my coding skills, but in the meantime, I'll really on my human brain and real time trades to figure this out.

Why I'm Trying These

To do something new and expand my trading repertoire. If I can sprinkle a spread strategy with my other strategies, it can benefit my bottom line.

Most importantly, I view a spread trade differently that just a regular 'go Long' or 'go Short trade'. Sure, I want UNH to go up  and WLP to go down; that would be ideal. But the way I really look at it: I want UNH to go up faster than WLP or I want WLP to go down faster than UNH. I'm not trying to be green on each stock, just green on the spread. So I'll probably have one winner and one loser, but overall net positive. Also, there's less anxiety about market direction.

So there it is. This spread stuff is a work in progress. I'm just glad I found some cool people in twitterland that introduced me to the idea. I know I'm not considering many factors like half life or Pearson correlation, but in due time. Let me know if I am on the right track.

Cheers!

-----------------------------------------------------------------------------------------------------------------------

This is the Catalyst Corner report, click to enlarge.

16 comments:

arisdavid said...

Well thought out Chris.

You have to think about your position sizing as well because the spread can go the other way for a long time (sometimes never to return to the mean).

Chris said...

yeah, always a concern. Right now, I am not risking much of my total capital. The $10K mentioned in the post was just hypothetical. I also need to figure out a the best way to close a losing trade.

Michael Bigger said...

Nice post. I will guest post it next week. When doing spreads do small size.

Dynamic Hedge said...

Great site. Look forward to following your progress. Feel free to ask questions. Happy to help where I can.

sjev said...

Hi Chris,

Your quanting life could be a lot easier if you were able to write in a descent high-level language. Matlab ,Python and R are very good candidates.
Yes, it takes more work than in a dedicated trading package like Amibroker, but on the bright side there are no limitations at all. You can automate anything, from pair scanning and back testing to order submission to IB.
Maybe you could 'join forces' with someone who is familiar with programming. Drop me an e-mail if you are interested.

Anonymous said...

Great site. A good site to find highly correlated pairs trades is pairslog.com. There is also a software program called "pairsfinder." I use both, then go t catalyst corner to check for cointegration.
Cheers

Anonymous said...

How do you graph spreads in Amibroker?

Chris said...

Google "amibroker spread chart" or something like that. Maybe add "linear regression". I didn't code it myself so I know it's on the web.

Anonymous said...

You can also try Pair Trade Finder (www.pairtradefinder). Currently it analyzes pairs based on correlation, but the next version will include cointegration.

I also use Ambibroker and would love to develop a scan that can look for and backtest correlation and cointegration. Anybody interested in teaming up please email me at pwiatheewsi@dunflimblag.mailexpire.com

Brian said...

Hi Chris,

Great blog - I really enjoy your updates. Quick question, I also use Amibroker, how did you get a "dollar neutral (almost) spread" on the bottom chart? That just looks like a normal price chart to me.

Thanks,

-Brian

Chris said...

Brian - email me: simplequant at gmail dot com. I will send it to you. It simply is a code I concocted.

-Chris

Anonymous said...

Hi Chris,
You would find using indices easier to use like FTSE and DAX; S&P and FTSE, CAC and DAX. These are used by CTA hedge funds since indices show better cointegration than individual stocks which are suseptible to events eg. BP oil crisis or missed earnings announcement. You will get hit badly in doing single stock spread trades. As for exit strategy, you can use bollinger bands for entry exit or moving average envelopes.
Regards
John

Chris said...

Thanks John

bullishtech said...

I've recently taken an interest in spreads and have put together a script written in R that searches my universe. http://quanttrader.com/public has some great info to help with this endeavor.

I have some other R code spitting out the spread daily data points which I then snarf up in Amibroker. I'll perform my back-testing in AB on these data. Completely agree with wanting to backtest. Being new to spreads as well,I'll be spending some time pouring over some theoretical trades myself. Will most likely join Mikes service to see how the pros execute.

I do have one question for everyone... what is the advantage, or reason, for using a dollar neutral multiplier instead of the hedge ratio derived using TLS or OLS?

tim_hare said...

Am interested in this myself. Will check back and see how things progress. Here's a link to a pairs-trading package in R:

http://www.r-bloggers.com/pair-trading-strategy-how-to-use-pairtrading-package/

Cheers!

TheSapper said...

Hi Chris,

Just out of curiosity, did you ever get anywhere with spread trading? I'm a software developer and automated day trading (but trading successfully since '08). I'm looking to expand my horizons and spread trading is intriguing to me (although I know very little about it). I have quite a bit of intraday market data on US Equities, but I have no futures or options data.

Anyway, are you interested in discussing anything having to do with spread trading and me doing the software development work? I'd (of course) want to know if you think there are ways to generate consistent profit in spread trading.

Thanks,

Jason

Post a Comment