Hi Per. I got an email today notifying me of your post to this discussion. I've been trading this algorithm during this entire time, as well as having a lot of email exchanges with Jonathan Kinlay regarding how to implement both the Johansen code and the Kalman filter in a manner similar to Chan. The algorithm was working well for me until about 2 months ago when one of the components of my triplet started rising in price in a way that appears to violate the cointegration. The result was that I waited 9 weeks for mean reversion. The portfolio finally mean-reverted, but by that time I had taken a significant hit on my profits. As a result my total trading profit over this time is much smaller than it was before this event -- around 10% or so over the past 9 months.
The past 2 months are clearly an outlier as compared to past algorithm performance. I can tell that simply by looking at the variation of the z-score over the past 10 years. The average half-life for mean-reversion of the z-score was 1.17 weeks. On a few occasions it took as long as 4 or 5 weeks to mean revert. (Remember, I don't make a profit until the portfolio value -- and thus the z-score -- mean-reverts.) Over the past 2 months or so, it took 9 weeks for my portfolio to mean revert. Is the cointegration breaking down, or was this just a one-time statistical fluke?
The problem is that when I re-calculate the Kalman filter parameters each weekend, the z-score often shifts in such a way that losses can accumulate if the mean reversion is delayed for too long. For example, on the close Friday, I may show a z-score of around 1.0. Over the weekend I re-calculate the Johansen test + Kalman filter parameters, and then when I run the algo on Monday morning, the z-score is significantly lower (in the range 0.5 - 0.8), even if the market is essentially unchanged. Thus, even if mean reversion occurs that day, I don't make as much profit as I'd hoped. This isn't a big deal if the portfolio mean reverts within 3 weeks -- I still make a profit. But if mean reversion doesn't happen for more than 3 or 4 weeks, I may end up with a loss. Waiting 9 weeks for mean reversion accumulated a 12% loss, which was more than half my profit over the past 9 months.
I'm still trading with this algorithm, but I'm waiting for a higher z-score before I "pull the trigger" on my trades, in order to increase the probability of a quicker mean-reversion. This means I may miss some trades, but that's OK. Also, I scale in my buys. (Partial buy at, say, z-score = 1.0, and another partial buy at z-score = 1.5, etc.)
If you're interested in how I implement the Kalman filter -- which is significantly different than Chan -- I wrote a detailed post on StackExchange - Quantitative Finance:
Does Chan use the wrong state transition model in his Kalman filter code?
Using a careful analysis, I argued in my post that Chan uses the wrong state transition matrix, i.e., the identity matrix, in his Kalman filter. I showed how to calculate the correct state transition matrix for a cointegrated portfolio, as well as how to initialize the Kalman filter using an adaptive tuning method. I received positive feedback from the readers of the forum, and one reader emailed Ernie Chan. This precipitated an email exchange between Ernie and I. Ernie basically said that his treatment was meant to be more general and so he didn't assume cointegration. I didn't want to argue, so I let it go. (My method actually works when there's no cointegration -- you basically get the identity matrix solution that Chan uses in that case.) Chan replied that "a stationary [cointegrated] portfolio can be more profitable", and that "your analysis may be correct". I didn't press him any further. I know what I did is correct, and none of the readers of my StackExchange post criticized my analysis. I received a fair number of up-votes.
I hope this is helpful.