I am looking to optimize the open/close signals and time for a pairs trading strategy my partner and I are researching. We don't want to go p-hacking so we have been trying to decide:

  • We have 20+ years of data. I believe that using this entire data set may lead us to the wrong conclusion and that the appropriate mean and sd of the pair may have changed over time, so we are trying to isolate the appropriate time period to identify the basic signal parameters. We could test a bunch of different time windows, but I think that takes us down the p-hacking route. Thoughts on how to isolate the relevant time period without introducing bias.

  • Once we isolate the signal (after conquering the above issue), we want to optimize when we the signal is at its most divergent within a reasonable time period, and optimize the mean reversion period. I imagine this relates to the edge that the signal has, but am not sure. Let's say we decide that the signal becomes relevant at 2 sd, how can we not reasonably miss if the signal is going to continue to expand beyond 2 sd? I guess that is directly related to the edge we are looking to obtain (if there at all) and our risk tolerance. And the same question on when the signal is telling us to exit. If we have one hard parameter again, lets say 2 sd, we could be entering and exiting at that point all day long and only incurring transaction costs, but not exploiting the signal. Again, this leads me to think that it depends on: a) the maximum edge in the signal available, b) how much of that edge we are willing to take or risk. Basically we are looking to identify in the signal the optimum entry and exit triggers.

  • We also have a few different pairs we can look at, about 10, but again, we don't want to p0hack, but we want to test each potential pair without inserting bias. My initial thought was just test them all, but my partner said "p hacking" - and the same thought he had with the mean reversion period. We can't look at the data to identify it, we should have a clue and test, which is reasonable, but I it seems counter-intuitive to NOT use the data to tell us when the mean reversion is occurring.

Any thoughts appreciated.

  • $\begingroup$ no disrespect, but this 'undergrad experimentation' territory. no one is using straight single-name equity pairs trading to make money at this point--probably not surprising as it was first developed in the 80s. people use some manner of correlation in trading otherwise, but I'd suggest you're wasting your time on this unless you're just exploring. that said, I've read read the Vidyamurthy pairs trading book and it's serviceable...would probably start there and see what speaks to you if I were in your shoes. $\endgroup$
    – Chris
    Nov 19, 2019 at 7:15
  • $\begingroup$ absolutely agree, this is not single-name nor equity, but i really can't share details beyond that. i will take a look at that book, thank you for the advice, much appreciated. $\endgroup$
    – Bikenfly
    Nov 19, 2019 at 13:40
  • $\begingroup$ and i just bought the recommended book. thanks again. $\endgroup$
    – Bikenfly
    Nov 19, 2019 at 14:46

1 Answer 1


This question is probably too broad and should be closed, but I will hazard an answer and leave it open for a period of time, until it accrues some close votes..

It seems to me that any machine learning model will be:

a) Somewhat based on assumptions about the structure of the data and the underlying problem to be solved. b) Based on using the data to train the hyper-parameters of the model to perform optimally in some statistical sense.

That is you have to decide what are your assumptions. There may be data or non-data related ways of validating these assumptions to place confidence in them but then you have accept them. It sounds like assumption of mean reversion is one of them. And on top of that you seem to make a suggestion of a regime shift between mean reversion and non-mean reverting (although I suspect this is very difficult to detect with accuracy)

Next you have to parametrise your model. Some parameter might be assumption based and form part of above or, more likely, you will use the data to derive them. You will have to validate your model with non-snooping back testing to arrive at the best parameters.

As general guidance I have always sought to obtain models which result in trades at the frequency which is economically viable. For example, I do not have the data speeds to be a HFT, so the data I use is low frequency, and given the cost of trades I need a trading period which is many days if not weeks or months.

I would, as you call it, p-hack which pairs are more susceptible to trading, but I would not search the entire space: I would selectively do so based on an assumption. For example in a space of pharma stocks and bank stocks I would only ever pair any stock of one type with the same type. But this is based on my assumption that there are more likely to be structural, long-term, pairs relationships between similar types, and not cross-types.

  • $\begingroup$ Thanks for the response, greatly appreciated. $\endgroup$
    – Bikenfly
    Nov 18, 2019 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.