Co-integration and pairs trading

msardelich

Newbie
Messages
2
Likes
0
Co-integration and pairs trading
I am backtesting some pair trading systems using Welath-lab.

The metric that I implemented to choose the best pairs is the minimum deviation from normalised spreads, considering 2 years (the same metric of Goetzmann paper).

Things are going fine but I would do it in a more scientific way. I mean to choose the best pairs based on co-integration.

The idea is to run a Dickey-Fuller test or, in other words, regressions of type:

Delta (spread) = a + b * (spread) + {White noise}, and test the null hypothesis that b=0 (with 99% confidence interval).

Anyway, other regressions will be necessary in other to guarantee beta neutrality between the co-integrated pairs.

I understand that WL is not able to support the pairs selector module, the regression computation, so the idea is to develop the regressions in a more sophisticated numerical package.

My question is: What´s is the best software to implement regressions: MATLAB or Mathematica ?
 
I don't know the answer to your question, but I'm sure someone will be able give you the load down the the merits of these packages on one of the forums here: http://www.wilmott.com/home.cfm?NoCookies=Yes&forumid=1

If you want a practical solution in terms of Alpha & Beta Coefficents, etc, then I think you'll find that Technical Analyst software will allow you to run your Betas against any instrument you want to - rather than a single "market" index - which is normally done on the basis that this index acts as proxy for the market return as a whole.

This means that you’ll be able to determine the risk of individual instruments within market sectors and sectors against the wider market indices, etc, which is normally quite useful stuff to know.

You can get a free trial of Technical Analyst software here: http://www.updata.co.uk/freetrial2/

HTH

Cheers

Mayfly
 
Mayfly,

Thanks a lot for the advice. Since, last thread I could find what I was looking for.

There is a very complete MATLAB library developed by Le Sage (http://www.spatial-econometrics.com/) from University of Toledo. Better, it´s a public domain toolbox.
The library will help me to catch the best cotintegrated pair through Augmented Dickey-Fuller tests. I believe that it will be much more effective than decisions based on simple correlation metrics between the target assets.
After the pairs scan I will run the performance back test using Wealth-Lab.

Thanks for sharing.
Marcelo.
 
Pair trading selection thru cointegration test

Hi from Paris France
I share the same concern : I am looking around a system to select among hundreds of stocks the best cointegrated pairs to create a portfolio. Using Matlab might be a solution. By hand. Very Time consuming. I am looking for an affordable system to make it automatic... Any idea...? I found this Johansen excel test : Uploads
But it might need to be automatic thru VBA script... Another way would be to use Alphacet platform, but expensive pro tool...



Co-integration and pairs trading
I am backtesting some pair trading systems using Welath-lab.

The metric that I implemented to choose the best pairs is the minimum deviation from normalised spreads, considering 2 years (the same metric of Goetzmann paper).

Things are going fine but I would do it in a more scientific way. I mean to choose the best pairs based on co-integration.

The idea is to run a Dickey-Fuller test or, in other words, regressions of type:

Delta (spread) = a + b * (spread) + {White noise}, and test the null hypothesis that b=0 (with 99% confidence interval).

Anyway, other regressions will be necessary in other to guarantee beta neutrality between the co-integrated pairs.

I understand that WL is not able to support the pairs selector module, the regression computation, so the idea is to develop the regressions in a more sophisticated numerical package.

My question is: What´s is the best software to implement regressions: MATLAB or Mathematica ?
 
Hi all,

I joined this forum thinking I would see an answer, but there are only questions :)
Marcelo, the regression Delta (spread) = a + b * (spread) + {White noise} and the test you want to make is not a Dickey-Fuller, it's just a statistical significance test. A T-test or F-test for model validity is the ones you're mentioning.

Regards
Andre
 
Matlab is good for most stuff, but is expensive for an individual. Mathematica is much better for symbolic maths, and is not so well known for its suitability for building analytic systems. Also expensive.

R is a statistical package that is used in many academic institutions and very widely on the trading floor of most Investment Banks with an interest in researched quantitative trading. It is industrial strength, has its packages continually added to and is comparable speedwise with Mathematica and Mathcad. It is also open source and free. The time series packages compare especially well with their commercial counterparts, as the leverage pretty much the entire academic community. And you can get beautiful graphical output as well.

Sorry for late contribution, but I hope this plug is useful.
 
msardelich,

I would have to agree with MrGecko, the MATLAB webinar is superb and there is code support on the MATLAB central website.

You can use the Dickey-Fuller or ADF test for cointegration if you're sure you have an exact method to linearly combine the two series. The DF/ADF test is primarily used to test for a unit root in one series. Much better to use the Engle-Granger 2-step or Engle & Yoo 3 step approach. You could use Johannsen, but it would be overkill seeing as you're only comparing two series at any one time.

Best of Luck.
 
You could just write your own solution to in C++/C#/Java too. The DF measure is useful but there are cruder methods which may be easier to implement. For example remembering that two co-integrated time series can be combined into a linear combination with constant SD and Mean. You could just create your optimal linear combination using linear regression then divide your data into say five samples and compare the SD and Mean for consistency. In other words we are looking for a small SD(SD) and SD(Mean). Crude but easy to program.
 
I wanted to share with everyone a Stock Pairs trading system that has been successful for me for the last 3 years, in both up and down stock markets.

Check it out at: http://stockpairs.collective2.com
and commentary on it at:
http://seekingalpha.com/author/rajeev-seth/instablog
:clap::clap::clap::clap:

This trading system screens for matched stock pairs to go long and short by doing a daily proprietary quantitative analysis of all stocks in the S&P500 Index

It may find a new entry trading signal consisting of two legs: a buy stock order and a simultaneous sell short stock order on a matching stock in the S&P 500. This computer screening generates an average of one or two paired trades per week. This gives you plenty of time to manually implement the two stock transactions in your brokerage, buying one stock and selling short the other when opening a new pair; or selling one stock and buying back a shorted stock when closing an open pair.

Our trading signal consists of simple instructions of the kind:

Buy 1000 shares of EQR, while
SIMULTANEOUSLY selling short 575 shares of VTR

You need to implement this trading signal by buying and selling both legs of the matched stock pair. You may execute the paired trading signal within a few hours of the system issuing the signal. It is very important to implement the two stock trades together, preferably on the same day, so as to derive the full benefit of the arbitrage potential in the stock pairing.

We will also provide you the closing signal on the trade pair, usually within a few weeks. Again, you must get out of the two legs together when your receive our exit signal.

Since there is plenty of time to implement the two trades, you can go about your business or hobbies without being glued to the financial markets. All you need to be able to do short selling is to open a margin account with your discount stock brokerage.

Use the trading signals given directly, instead of needing to construct a system yourself
 
Not at all, there is no crash-burn here.

the signals are doing well, exactly what it is designed to do.
Look carefully at the statistics below on the following link

http://stockpairs.collective2.com/cgi-perl/system51314973#

It shows it has annual return of 13% and sharpe ratio of 1.45, with low drawdown of 5%

Unlike other systems that are crashing and burning in the last 3 months, this system's equity chart has been steady

@beatindex,

What happened to your signal? Crash and burn?
 
Am I reading it right .... or is that an annualised return of 2.1% ???

Hey, why are you staring at a stopped clock. I stopped posting signals there after Jan, 2011
Look at the last trades shown there. when were they posted. So, do not draw wrong conclusions from an inactive website. While the system was active, it performed well
 
hey, why are you staring at a stopped clock. I stopped posting signals there after jan, 2011
look at the last trades shown there. When were they posted. So, do not draw wrong conclusions from an inactive website. While the system was active, it performed well

lmao
 
Top