Spread (pair) trading question

Discussion in 'Strategy Building' started by IIAce, Mar 13, 2006.

  1. IIAce

    IIAce

    I understand the basics of pair trading. However, there's something I can't resolve and I haven't seen it resolved in anything I read so far online.

    Say I want to make a pair trade with FDX and UPS. Now, I get their historical prices for one year, find the ratio of the two prices, the mean, and the standard deviation. Now, say that right now the ratio is two standard deviations away from the mean so I make the trade. The objective is to close the position when the ratio returns back to the mean, but here comes the problem. I can check every day for whether the ratio reached the mean or not but which mean do I check? The mean that was used when the position was originally opened or the mean of all the ratios since a year before the position was opened until now?
     
  2. Doesn't look like a good pair to me.. a good pair would be one where there exist a linear combination such that they trade at some fixed ratio to each other.. with this pair there clearly is no mean and would be called 'non-stationary'. So, there would be no mean and you would probably trade it just as you would a single stock, except that this series is probably more reverting than trending.
     
  3. IIAce

    IIAce

    You sound like you know what you're talking about :D. I got "Pairs Trading" by Vidyamurthy and tried to read through it. I understand pretty much all of it, but just can't apply it. For example, to calculate the coefficient of cointegration, I need to split stock prices in two components: common factors and specific factors. He doesn't really say how to do any of that. Also, how can I actually apply the APT concept if I have no way of finding the exposure factors of a stock?

    Anyways, yes, the problem is that stock prices are non-stationary and the mean (and standard deviation) change with time. How can you practically take care of that problem? How can you actually find the linear relationship between the two stocks? Do you know where I can learn about all this? Is Vidyamurthy's book really all I need and I'm just not putting enough effort into it?

    I assume if I know the answer to the previous questions, I'll know the answer to my original question regarding which mean value to use.

    Appreciate the help.
     
  4. vidyamurthy's book is pretty good, but pretty light on implementation details.

    Stock prices are always going to be non-stationary.. the whole allure of pairs trading is that the spread is supposed to be stationary (in a perfect world), or at best, highly mean-reverting.. 2-stock pairs that are truly cointegrated are really hard to find..

    A really simple way of finding the cointegration coefficient is doing a simple regression of one stock against the other (using log prices always of course), this is the engle-granger method. Take the residuals from that regression and test it for stationarity (dickey fuller tests, etc). It probably isn't going to be stationary for most "pairs", but it is probably going to be much more reverting than either of the stocks themselves.

    This idea can be extended to any number of stocks, but then you have to decide which stock to use as the dependent variable, and depending on which one you use, it'll give you different coefficients, for this reason I prefer the johansen method. You can find code for this in matlab, some econometrics packages, etc. I don't know of anyone who has implemented johansen method in excel.. that'd just be asking for it. The normalized ratios of the cointegration coefficients are your hedge ratios.



     
  5. IIAce

    IIAce

    I never really took a statistics course so I'll be trying to learn. I have a few questions though: When you use the log of the prices, you use log base e not 10 right? When you do the regression between two sets of log(prices), you get an equation y = mx + b. m is the cointegration coefficient right? What exactly are the "residuals" of the regression? After I test those for stationarity, how do I decide whether the pair is "good" or not?

    I realize that I have a long way to go if I don't know the answer to those questions, but everyone's gotta start somewhere :D.
     
  6. I didn't know any of this shit 6 months ago, it shouldnt take too long to figure out if you dont mind sleeping much. :p

    natural log, e, yeah

    The residuals are just the error left over from the line fit.

    If the pair is stationary, it is good, even if it is not stationary it might still be pretty good because of the more predictable nature..


     
  7. gkishot

    gkishot

    How are you guys going to get around the problem of paying interest on short positions?
     
  8. IIAce

    IIAce

    I have an account with Scottrade and asked them about the interest issue. They said that they don't charge interest on shorts. I think you can't use the proceeds from shorts to buy long though so the strategy doesn't "pay for itself" as it should.

    stephencrowley, you forgot to answer one question: The m in
    "y = mx + b" the cointegration coefficient right? So basically, it's just the slope of the line that minimizes the residuals eh?

    Thanks
     
  9. Right, m is your cointegration coeffecient and b is the intercept.. you probably want to look at the histogram of residuals, skewness, kurtosis, etc

     
    eurusdzn likes this.
  10. gkishot

    gkishot

    This is very unlikely because they borrow this security and they have to pay an interest on it which they are going to pass surely to you. Treat it with caution.
     
    #10     Mar 14, 2006