A Simple Approach To Find The Hedge Ratio For A Pairs Trade

Discussion in 'Trading' started by TheBigShort, Oct 28, 2019.

  1. B4 you invest in ‘deciphering’ Toda and Yamamoto, you might want to scan the www for some/any implementations based on their approach. After all, they themselves acknowledged that their method is greatly inefficient.. (dee discussion...)
     
    #21     Nov 3, 2019
  2. TheBigShort

    TheBigShort

    @Kevin Schmit can you explain why the impulse response function (IRF) is important in pairs trading? Why do we care about how a shock in Y1 affects Y2? I am under the assumption that I want to know when Y1 (the error correcting leg) is too far from equilibrium.

    There were a few papers on the OU model for pairs trading, but I really like the vars package and I have done a few examples with the Canada and Consumption data sets. I am contemplating Richards recommendation and start on "New Introduction to Multiple Time Series Analysis"
    but 750 pages is quite a big investment. With that being said, the table of contents look juicy. What do you think?

    Do you have SVECM/VECM R code lying around? Here is a paper about using VECM for pairs trading. https://pdfs.semanticscholar.org/f679/401a111f47005533e0f04f4809b8d8f4887b.pdf They created a VECM model and plotted the residuals. The graph has clear buy/sell signals.
    Screen Shot 2019-11-14 at 2.13.17 AM.png
    This is how I pictured it. I find a group of cointegrated pairs -> create vecm -> see how far current residual is from mean -> place trade using beta/intercept from model as hedge ratio (long/short for now until i start doing only error correcting leg).

    A major feature of a VECM model is the IRF and the longRun-shortRun effects. I am having a hard time seeing how this fits into pairs trading. I understand that creating an actual profitable strategy is going to take a few months but I am a bit lost on where to place my next step. The AR family is so broad Kevin, if you could narrow it down for me a bit that would be greatly appreciated.
     
    #22     Nov 14, 2019
  3. The shortest answer is that your question is answered in exhaustive detail in the Lutkepohl book you reference below. Except, not being Canadian, Lutkepohl uses German consumption/income data and IRF analysis to show that information flows generally from [shocks to] income to changes in consumption but not vice versa (or maybe it is the other way around).

    A slightly longer explanation is to note the similarity between the calculation of IRF (or, more properly for a VAR model - FEIR, Forecast Error Impulse Response, which name should give you a clue) and Diebold's calculation of directional info flow. Both start from the MA representation (companion form) of the VAR (in fact, in a certain sense the FEIR is equivalent to the Companion Form). The FEIR alone isn't enough to derive contemporaneous info-flow or causality. However you can gain directional insight by multiplying FEIR by a matrix "F." There are many ways to estimate F or F%*%phi, Easiest if to use Cholesky decomposition:
    t(chol(summary(vmod)$covres)) where vmod is your VAR model. Or set ortho=TRUE in building your VAR model, I think it does the same thing. Lukepohl goes over a number of different approaches and explains it much better than I can.

    To sum up, you want the contemporaneous impulse response to figure out which half of the pair or which members of a basket VECM is error correcting. However it is not absolutely necessary for simple single pairs trading -- you'll be fine trading both sides of the pair in classic pairs trading fashion.



    By all means, stick with what you are most comfortable with. OU is flexible, tractable (i.e. Gaussian Process), easy to recast in state-space representation, and gives you a clear model of the DGP. However your real edge here will come from understanding your model inside out, and you're a lot farther along in the VAR space than you are in OU or state-space space.




    That is an excellent idea. The book is a classic and easily available online. The data used in the examples are available on the book's website.

    Nothing specific. I generally use VAR family models for exploratory data analysis and can usually coerce the vars package into doing what I want. When, in the past, I traded baskets of single pairs, I did not use (S)VAR for the final models,

    Thanks. I've put it on my reading list.

    Usually I'm a big proponent of stats analysis via visual inspection of plots. But not in this case. I've also never seen a bad hypothetical track record or unprofitable backtest graph.

    That should work. One other element you might want to add. I'll pm you on it.

    Skim the Lutkepol book. I'll take a look at the table of contents again (it's been a few years) and let you know which sections I think might be most relevant. For now, given your plan just above, you don't need estimates of one-way information. So just keep reading/studying and add in the bells and whistles later.
     
    #23     Nov 14, 2019
    TooEffingOld likes this.
  4. TheBigShort

    TheBigShort

    Thank you Kevin for your continued support. Your explanations have been extremely helpful. I hope down the road other ambitious traders find this thread.

    When I fit my VECM model should I fit it in levels (log(Y1), log(Y2)) or in the first differences. I have seen the model used with both for the same underlying. My prior would be to fit it in levels.

    I am going to shoot Diebold a email. Pen U in only a 4 hour drive from me! I think he could really help me out. I wouldn't mind stopping off in Grove city for some shopping either!
     
    #24     Nov 14, 2019
  5. TheBigShort

    TheBigShort

    "A New Approach to Modeling and Estimation for Pairs Trading" Binh Do ∗ Robert Faff † Kais Hamza ‡
    This paper talks about a pairs trading strategy in the return space. Looks interesting, but I am going to stick with with VECM/SVECM in the levels(price) space. Correct me if I am wrong.
     
    #25     Nov 14, 2019
  6. @TheBigShort how did this end up working out? Are you trading it?
     
    #26     May 30, 2020
  7. TheBigShort

    TheBigShort

    No, I got side tracked by another strategy I am running. The main issue I had with pairs trading is structural shifts - you build a model around a pair and then once you start trading it, there is a shift. I turned to a hidden markov model to assist me which then made me realize, I probably need to work with a team for at least a few months. At the time I was focused on vol so making this switch didn't make sense.

    It was a great learning experience tho and an intro into d1 trading. I learned a lot from the research. If you decide to give it a shot I will be more then happy to pass on what I've learned.
     
    #27     May 30, 2020