Pairs Trading

StrataSearch has many powerful features, with many techniques and approaches to explore. Here we discuss the things we've done, and the things we'd like to do.

Pairs Trading

Postby rjay » Sat Sep 22, 2007 1:09 pm

I just wondered if anyone had attempted to do Pairs Trading (sometimes known as spread trading) in Stratasearch ? In other words, measuring the relative strength between two indices/stocks/sectors and looking for times when (for example) the spread reverts to zero so that one could place a long & short on stock a & stock b respectively, looking to profit from when they diverge again.

It would be great if I had a OneClick which scanned for the best two instruments based on previous divergences.
rjay
 
Posts: 116
Joined: Wed Jul 26, 2006 6:51 am

Postby Overload » Sat Sep 22, 2007 2:05 pm

That's an interesting idea. I've not tried it myself, but I believe the only way you could do that right now would be to have an existing index based on the ratio between the 2 products. Unfortunately, there's not an easy way to create such an index, so implementation would either require some manual work or an external program to create it.

I'm going to consider this a bit more. As we ultimately work toward realtime trading, pairs trading is going to be in greater demand. We'll have to think about how that's going to work. Thanks for bringing it up.

Pete
Overload
 
Posts: 2248
Joined: Wed Nov 30, 2005 12:14 pm

Re: Pairs Trading

Postby taowave » Sun Sep 23, 2007 3:28 pm

Hi Rjay,
I have traded pairs in the past,but had programmers doing the work for me.I have never attempted this in SS.Pairs trading is often referred to as statistical arbitrage,and more often than not takes pairs of stocks within the same sector that has shown a high degree of correlation in the past and a current divergence.

Most of the effort comes from setting up,maintaining the database and monitoring the "tradable pairs",which could be by sector,but more likely by industry.I think you may find that task a bit overwhelming in SS..

Just my two cents..



rjay wrote:I just wondered if anyone had attempted to do Pairs Trading (sometimes known as spread trading) in Stratasearch ? In other words, measuring the relative strength between two indices/stocks/sectors and looking for times when (for example) the spread reverts to zero so that one could place a long & short on stock a & stock b respectively, looking to profit from when they diverge again.

It would be great if I had a OneClick which scanned for the best two instruments based on previous divergences.
taowave
 
Posts: 584
Joined: Sat Dec 02, 2006 12:39 pm

Postby Overload » Sun Sep 23, 2007 7:56 pm

Now that I think about it, this might not be so hard after all. My initial thought was that we would need to create an Index to analyze the ratio, but that's not really necessary. You can just use the symbol() formula to reference whatever you wish.

As an example, suppose you wanted to do pairs trading on MSFT and AAPL. You could just create a rule like this:

diverge(symbol(MSFT, close), symbol(AAPL, close), 2, 10)

When you have a positive divergence, you should short MSFT and go long with AAPL. Likewise, with a negative divergence, you should go long with MSFT and short AAPL.

You could also measure the lead-up correlation between the two by adding a supplemental rule like:

and cor(symbol(MSFT, close), symbol(AAPL, close)) > .90

I'd have to think a little bit more about how one would set this up, but I'm guessing you'd need to use a Portfolio Size of 2 and have 2 strategies in a Multi-System where each would allow the proper symbol to be bought long or short as needed. Nevertheless, I'm pretty sure it could be done.

There's unfortunately no way to automate this across a large basket of symbols. So, as Allan said, there would be a great deal of setup to this if you wanted to do it across quite a few pairs. But, if these base definitions were set up as trading rules, I suspect you could have an AutoSearch or OneClick investigate supplemental trading rules for you. Again, I haven't tried it, but I'm pretty sure it can be done.

Pete
Overload
 
Posts: 2248
Joined: Wed Nov 30, 2005 12:14 pm

Re: Pairs Trading

Postby Jaded » Sun Nov 03, 2013 7:20 pm

I'm trying to do this right now and create a system that uses my (Long only - 1 strategy) multi-system to trade SPY (S&P 500 Long ETF). What I want to achieve is to automatically have the system ( a second inverse strategy? ) go long in SH ( S&P 500 Short ETF ) whenever the first strategy is not in the market.

I know I could just do this manually in my trading, but I'd like to have the statistics for the idea available in StrataSearch to view and compare.

My initial thought was to create a second strategy that enters upon hitting the first strategy exit rules, and exists upon hitting the first strategy enter rules. I tried this a few times, but couldn't seem to make it work 100%.

I'd like to hear your thoughts on how this would be possible with SS.

Thanks!
Jaded
 
Posts: 151
Joined: Mon May 14, 2007 6:49 pm

Re: Pairs Trading

Postby Overload » Mon Nov 04, 2013 9:07 am

Sorry, but there isn't a feature in StrataSearch to do this. Any processing to force a system to be short when it's not long, and vice-versa, needs to be programmed manually.

Pete
Overload
 
Posts: 2248
Joined: Wed Nov 30, 2005 12:14 pm

Re: Pairs Trading

Postby marco » Mon May 23, 2016 5:52 pm

Usually when trying to identify tradable pairs one uses the ratio of the pair, sets a number of deviations from the mean and runs a test to see which pairs performed best historically. I would like to approach this from the other side: Select a pair and then find the optimal settings for SD entry and exit and lookback period for this pair (and possibly their industry). I tried this:

entry:
symbol(KO,close)/symbol(PEP,close) < bbl((symbol(KO,close)/symbol(PEP,close)),@days,@dev) or
symbol(KO,close)/symbol(PEP,close) > bbu((symbol(KO,close)/symbol(PEP,close)),@days,@dev)

exit:
symbol(KO,close)/symbol(PEP,close) < bbu((symbol(KO,close)/symbol(PEP,close)),@days,@devexit) and
symbol(KO,close)/symbol(PEP,close) > bbl((symbol(KO,close)/symbol(PEP,close)),@days,@devexit)

If I run this against a single symbol I can check the number of trades that were generated and draw some conclusions, but obviously I would be interested in the results of the pair trades. Can this easily be done in Stratasearch?

I did try the following: create 4 sectors, KO short, KO long, PEP short and PEP long. Then create 4 different strategies and put them in a multi system. But the trades don't match because KO short may look at another deviation and lookback period than PEP long. Is there a way to let the strategies use the same variables across a multisystem?
marco
 
Posts: 52
Joined: Mon May 27, 2013 6:15 pm

Re: Pairs Trading

Postby Overload » Mon May 23, 2016 6:46 pm

Sorry, but StrataSearch does not have integrated support for pairs trading.

Pete
Overload
 
Posts: 2248
Joined: Wed Nov 30, 2005 12:14 pm

Re: Pairs Trading

Postby marco » Tue May 24, 2016 2:20 pm

I understand, but I'm merely trying to use Stratasearch's automatic variable search function to find the best settings for a pair.
It can be done though, but I need to use only 1 strategy in the multisystem and assign the two different symbols to a long and short version of the same strategy.

Entry:
symbol(KO,close)/symbol(PEP,close) < bbl((symbol(KO,close)/symbol(PEP,close)),@days,@dev)
Exit:
symbol(KO,close)/symbol(PEP,close) > bbl((symbol(KO,close)/symbol(PEP,close)),@days,@devex)

Create a multisystem of 2 strategies and assign KO as sector for the long trades and PEP as sector for the short trades.
This works fine, although it had me puzzled for quite some time as to why every time I had a few trades where only one of the symbols would trade.
Of course I had to set the Best/Worst trade setting to zero..

Next create a mirror version for short KO/ long PEP.

The optimal entry/exit settings will be different for long KO/short PEP and short KO/long PEP, but well, who said they had to be the same in the first place?

This is all pretty labor intensive, but maybe at some point someone will find this useful.
marco
 
Posts: 52
Joined: Mon May 27, 2013 6:15 pm


Return to General Discussion

cron