I have had some success with short term pair trading strategy but can't figure out how to backrest it.
I identify pairs for the first few hours of a day and then trade them for a few hours the same day. I used notebook to find the pairs on a random day by comparing all stocks which is very time consuming. Then I hard-code these few stocks into an algorithm that runs for just the same day. I did this for a few days with good results.
By design, these are not real macro-economic pairs. They are just statistical pairs for a short time. As a result, I can't use the same ones everyday.
Currently it takes over an hour to identify the pairs. I cant have that happen once a day for the backtest.
Any ideas on how to speed this up?
Perhaps some way to filter out stocks that certainly can't be pairs. Or a way to get 'almost pairs' and just check those each day.
I expect this not to work when I backtest it, but I would like to know.