Pairs Trading Execution Risk

Hi All,



I have found some pairs that are profitable when I worked with the current price in backtesting.



However, I have realized that the backtesting with the current price is an illusion due to unfill risk.



For example, when my machine sends me a long entry signal, I might have to "short A" stock, and "long B" stock. If you send "limit orders" for both stocks, there will be 4 cases.


  1. A filled, B filled - Great
  2. A filled, B unfilled - Not good
  3. A unfilled, B filled - Not good
  4. A unfilled, B unfilled - Not good



    This is only for the "long entry signal", moreover there are 3 more signals (long exit signal, short entry signal, and short exit signal). 



    There will be 16 cases (4 x 4) that we have to consider on the "execution parts".



    Due to the above execution risks, people set the "rebalance period" as 1 min, 30 mins, few days, and etc.



    If you would like to ignore the 16 cases, you could use "market order", but I believe this is not a good option for a trader.



    Because if we use market orders, then we will lose at least 4 ticks and it will make the trading profit poorly, and the result will be significantly different with testing.



    I would like to hear some trading experience of the exec risk from this Alumni. 



    Thank you.

There are two aspects to your question. One about the backtest:  if it makes sense to backtest assuming execution at the current price. The answer is of course, as you say, no. That is why a backtesting system should include an execution model to mimic real life. A first cut model will be to put a max execution volume limit where the impact cost is practically zero (say 1% of the total volume traded at that bar). If your strategy generate orders of X shares which is more than that limit, carry over execution of unfilled amount to the next bar, and so on. If you are using backtesting on your own, you need to implement such an execution model. Or you can try platforms such as Blueshift that already do it for you.



On the actual execution, some exchanges do support multi-legged execution - but they are mostly for same underlying. For pair trading with different stocks, you must implement your own execution algorithm and carry the execution risks. The execution strategy can define a certain level of "aggressiveness", and put a limit order. Then depending on the execution, "aggressiveness level" and per-trade expected profit, will keep on updating the orders till you get both legs filled. The algorithm to do this can vary from very simple (stand at x-ticks away from best bid/offer) or it can be very complex, depending on your strategy. This will not mitigate execution risks completely.  For longer holding periods, you can even leg in individually depending on some short term signals. Lower the profit per round trip and shorter the holding period, harder it becomes.

Thank you for the explanation. the explanation is the one of the best answer and definitely needed answer. I do appreciate your answer.

For the back-testing, I am using a KRX data and it is kind of hard to use Blueshift. As you have suggested, the first cut model was the one thing that I have thought about to minimize the market impact. Just got a quick question regarding on the 1% of the total volume traded at that bar. Does it mean 1% of the total volume of level 1 price or total volume of all level prices practically?

When I have learned about the Pair Trading in EPAT, it looked easy, but when I closely looked into that, there are many things to be considered. Thank you for sharing your practical experience again.

For the actual execution, sadly KRX doesn’t support the multi legged execution. One thing that I have learned recently was a longer holding periods, doesn’t guarantee the maximum profits. I might go ahead to implement the execution limits with 1) price movement limit 2) holding period limit. An Algorithm trading is very complex!

I agree, we do not cover KRX, I hope soon we will be able to offer something on this, one way or other.



If you have order book data you can do much better execution modelling. The 1% I mentioned was assuming you just have historical trade candles (OHLCV), where you can use the total volume traded at that bar as a guide to market liquidity available. Of course that works only for liquid stocks and one should not use this methodology for backtesting small caps.

Thank you for your time, Prodipta. Now, I am going to work on the execution methodologies. Have a wonderful weekend!

Thanks for the question from yay and great answer from Prodipta, how about exit order on both symbol A & B.



If both entry orders are filled on symbol A & B, when exit, if exit order is not filled, that's a problem.



Can we place market order for exit orders? Or limit orders might lead to unfilled order.



Please help on how we handle the exit orders and make sure they are filled?



Thanks

I think entry or exits are not really that different in this regard - so all of above should apply. Market and limit orders are two extreme ends of the balance between immediacy and best price. If your strategy is not execution based, you can decouple the execution from strategy. Reasons why you would prefer limit to market is low liquidity, high bid-ask spread, high volatility, competiting predatory strategies, asymmetric information etc. Reasons to avoid limit orders - execution risks, no cancel/update option, adverse market move etc.

Thanks for quick reply. I don't really fully understand your answer. What I am doing is testing the bot on production environment with different way for entry and exit and find out which one work best.