Page 2 of 2

### cointegration based pair trading

Posted: November 29th, 2011, 5:36 am
QuoteOriginally posted by: MarineA few things to keep in mind when doing your research:1. Where did you get the code for ADF? Is it correct?2. You mention ADF (which is a unit root test) in your post but you have not mentioned what co-integration test you are using.3. Just because your calculation tells you a process is co-integrated does not mean you will make money from it.4. Co-integration will exist at several different frequencies so maybe you just found a weaker one.5. Once you have the co-integration vector then how you plug that into your model will determine if you make or lose money. Maybe the problem is in your implementation.\$.02Hi 1. I am using inbuilt function in R. It is part of the R inbuilt library or package. 2. Stock1 = A*stock2 + spread, I have regressed stock1 against stock2 and used ADF.test on spread. Which is basically the residual based test for co-integration.3. Correlation implies stationary or mean reversion. what should I do to turn co integration to a profitable trading strategy? 4. I am having only daily equity data. I don't have other frequency data.5. Let us say the vector is [1, A] where I will take position on 1 share of stock 1 and opposite position on A number of shares of stock 2. I calculate the spread which is stationary as per ADF test. I take the position when the spread far away from mean and close the position when it return to mean. As per theory, I should make profit but having difficulty in implementation.

### cointegration based pair trading

Posted: November 29th, 2011, 9:37 am
Quote2. Stock1 = A*stock2 + spread, I have regressed stock1 against stock2 and used ADF.test on spread. Which is basically the residual based test for co-integration.3. Correlation implies stationary or mean reversion. what should I do to turn co integration to a profitable trading strategy? 5. Let us say the vector is [1, A] where I will take position on 1 share of stock 1 and opposite position on A number of shares of stock 2. I calculate the spread which is stationary as per ADF test. I take the position when the spread far away from mean and close the position when it return to mean. As per theory, I should make profit but having difficulty in implementation. 2. Have you tried Granger, Johansen, or Phillips and compared the results? What type of regression OLS?3. Correlation DOES NOT imply that a process is stationary!5. This is the most important part of your model. If you enter into a position to early or to late you lose money. If I buy low and sell high I make money but how do I know when we are at a high or low? You need to spend alot more time researching this part. As long as you can find one vector then the process is considered to be cointegrated but it is possible to find many vectors. Try one of the tests I mentioned above. They are part of the R library as well.A HINT ...Stop applying cointegration to a simple pair and try it with atleast 3 legs. There are easier methods to finding pairs which are more robust.

### cointegration based pair trading

Posted: November 29th, 2011, 12:26 pm
Marine you've got me intrigued ... 3 legs as in something like triangular arbitrage ? Or more of a Johansen type approach ? ie cointegrated vectors with more than 2 dimensions ?

### cointegration based pair trading

Posted: November 29th, 2011, 2:55 pm
QuoteOriginally posted by: MarineQuote2. Stock1 = A*stock2 + spread, I have regressed stock1 against stock2 and used ADF.test on spread. Which is basically the residual based test for co-integration.3. Correlation implies stationary or mean reversion. what should I do to turn co integration to a profitable trading strategy? 5. Let us say the vector is [1, A] where I will take position on 1 share of stock 1 and opposite position on A number of shares of stock 2. I calculate the spread which is stationary as per ADF test. I take the position when the spread far away from mean and close the position when it return to mean. As per theory, I should make profit but having difficulty in implementation. 2. Have you tried Granger, Johansen, or Phillips and compared the results? What type of regression OLS?3. Correlation DOES NOT imply that a process is stationary!5. This is the most important part of your model. If you enter into a position to early or to late you lose money. If I buy low and sell high I make money but how do I know when we are at a high or low? You need to spend alot more time researching this part. As long as you can find one vector then the process is considered to be cointegrated but it is possible to find many vectors. Try one of the tests I mentioned above. They are part of the R library as well.A HINT ...Stop applying cointegration to a simple pair and try it with atleast 3 legs. There are easier methods to finding pairs which are more robust.2. I am using linear model. lm is function in R for lienar model. I will test with other methods as well. I was applying adf test only for lag=0, you mean to say If it gives stationarity under adf test with lag=0,1,2,3 at least then we should go ahead and invest money?Idea: Why can't i apply the dynamic alpha method, the co-integration coefficient change everyday based on last lets say 20 day price.

### cointegration based pair trading

Posted: November 30th, 2011, 9:53 am
Quote2. I am using linear model. lm is function in R for lienar model. I will test with other methods as well. I was applying adf test only for lag=0, you mean to say If it gives stationarity under adf test with lag=0,1,2,3 at least then we should go ahead and invest money?Just because you think a process is stationary does not mean you should invest money in it. You need to run a backtest to see if it makes money. You can do a simple one first to save time and ignore fees and slippage etc... If it make money and the SR > 1 then you can progress to the next level. At this point your backtest should be as accurate to real life as possible. You need to ensure you have no bias in your model (which you will have if its a new unproven model). You only invest money in your strategy when you believe you got everything right and statistically you think it should make money. You always start small and scale it up once it has a proven track record.You need several ways to filter out pairs. Pnl and SR is not good enough by itself. Once you truely understand your model you will be able to come up with other criteria as well.QuoteIdea: Why can't i apply the dynamic alpha method, the co-integration coefficient change everyday based on last lets say 20 day price. I do not think you truely understand how to use cointegration. 20 data points is not enough data to test for cointegration IMHO. Cointegration is a long term relationship, if it changes when you shift one data point in your process then it's shit and I would NEVER trade off it. Please read more about it and the VECM.

### cointegration based pair trading

Posted: November 30th, 2011, 10:02 am
QuoteMarine you've got me intrigued ... 3 legs as in something like triangular arbitrage ? Or more of a Johansen type approach ? ie cointegrated vectors with more than 2 dimensions ? I was referring to Johansen and think humtumiit should spend some time reading about it.I have used triangular arbitrage in the FX world but you have to be quick to capture it. You can apply something similiar to it in the stat arb world by trading baskets. I would not call it the same thing but it is similiar and alot of people are doing it these days.Also trading DLCs are similiar in a way but requires alot of capital. LTCM lost money from this approach but it was not what killed them but it did not help.

### cointegration based pair trading

Posted: November 30th, 2011, 10:33 am
Ok, gotcha. Yup agreed that stock vs basket or basket vs basket is probably the way to go in order to potentially find something usable for trading. Essentially cointegrating vector > 2. Too easy to do the old simple pairs trade nowadays given tools like R etc and don't think there's much alpha left. It still takes some effort to get it right but still not that much in it as outlined traditionally I think, ie open trade at 2 standard deviations etc. Some people still do this at super high frequency and I've always questioned whether that is cointegrated pairs trading or more playing the microstructure effects and simply spreading risk. Think something like Johansen or other methods to give higher dimension baskets is more tricky to do right and hence why there might be some alpha left, as well as the benefits of increased diversification. Yup DLC's. Think a few people have been burned playing those. Recently I think the DLC's of two big UK/Australian mining companies probably smacked a few people.....I've still not read "When Genius failed" but if I've heard correctly what really hit LTCM was Russia defaulting on it's bonds ? At the time no one considered a sovereign would ever default. Luckily it was a one off and it's not likely to happen again so everyone now happily takes on sovereign risk without worry. Where's the sarcasm emoticon on this thing ? :0D

### cointegration based pair trading

Posted: December 12th, 2011, 7:58 pm
Also you could look at the fundamentals behind the pair.. CMCSA CMCSK for example, nasdaq

### cointegration based pair trading

Posted: December 13th, 2011, 11:54 am
QuoteOriginally posted by: humtumiitI am using 4 years of data to pick co-integrated pairs. I am regressing S1 ~ S2 over 4 years of daily data. I used ADF test to test for co-integration and list of pairs which are co-integrated. I found that spread is mean reverting or stationary but the rate of mean reversion is very slow. It returns to mean 2-3 times in 4 years of data. How the mean reversion rate can be increased such that spread reverts to mean more than 20 times in 4 years of data? I want frequent reversion to mean to reduce the number of days I am in the position. Reducing the trade length will help me realizing the returns so quickly rather than waiting for so long.I suppose 4 years it is very long period ....

### cointegration based pair trading

Posted: December 15th, 2011, 5:09 am
In co integration relationship for pairs trading, we regress S1 ~ S2 without intercept. But we know, regression without intercept increases R square dramatically. How to handle this? R square change dramatically, how can we say that this fitting is not spurious?

### cointegration based pair trading

Posted: December 15th, 2011, 7:24 am
QuoteOriginally posted by: MarineQuoteJust because you think a process is stationary does not mean you should invest money in it. Correct, even when you know that the process is mean reverting you should also not invest. IMHO you need to calculate the value function of your portfolio and decide afterwards wheter you should trade or not.Kim

### cointegration based pair trading

Posted: January 18th, 2012, 2:22 pm
You said you did a ADF test, but from what table did you get your critical values? did you performed the test with the DF statistcs?

### cointegration based pair trading

Posted: January 19th, 2012, 4:54 am
QuoteOriginally posted by: DantasYou said you did a ADF test, but from what table did you get your critical values? did you performed the test with the DF statistcs?I performed ADF test in R. Which gives critical values and t stats as an output. No I did not perform DF test.

### cointegration based pair trading

Posted: January 25th, 2012, 3:49 am
I mean ADF test. Because the thing is ,when you regress S1 ~ S2 using OLS you almost for sure turned the residual series stationary, because the criteria for minimizing the sum of square residuals is to set them equal to zero. So You should perform a CRADF (co-integrated residuals - ADF) (see the link)Other things that you have to be aware is that in case you choose an equation with deterministic variables (constants , trends ) and they arent significant, your test power gets lower and its something to worry, once they arent high. But in the case that deterministc terms are relevant and you omit them, your test power goes to zero. You also should be careful performing a Engle-Granger test, because once you set the regression, you implicitly choose a cause-effect relationship. So first think of the economic relationship that your variables might have and them set your equation. In the VEC you also have short-term deviations from equilibrium, not only the cointegration relationship that is "looking" to the long-run. IMHO you should do the johansen methodology. Mackinnon