Let me explain the algorithm first. The algo is based on pair trading EWA and EWC. I assigned a pre-defined weight to EWA and EWC in the algo in context.evec, which means if I order 0.943 share of EWA, I will order -0.822 share of EWC, and vice versa. Then I look at the combined price of the EWA/EWC pair weighted by their weights in the context.evec, which would be a semi-stationary price. I will have -h*context.unit_shares of the EWA/EWC pair, where h is the z-score of the combined EWA/EWC pair price. So this basically a mean-reversion strategy trading on the spread between EWA and EWC.
The problem I have is that this strategy relies on I can buy EWA/EWC at the price I want. However, when I increase the number of shares that I long/short, the price start to slip. For example, here I increase context.unit_shares to 200, which means I will long/short on the order of 200*z-score shares of EWA/EWC everyday. In this Full Backtest attached, you can see in the Transaction Details that the algo bought 125 shares of EWA at $20.38 at 2006-06-06 10:04:00, 150 shares at $20.34 at 2006-06-06 10:07:00, and 109 shares at $20.20 at 2006-06-06 10:08:00. But really what I meant is to buy (125+150+109) shares at the same price at once. However, if I set context.unit_shares to 20, I don't have the problem because I can buy 30 shares of EWA all at once.
This price slippage problem will basically kill most of pair trading strategy that has a small price spread, if you can't buy enough shares at the price you want. Can you give some suggestions on that? Of course the regulation on minimum short of $25K would kill the algo as well. If I have to short at least $25K, I am sure the price that I short the stock would be all over the place.