Quantitative Analysis, Risk Management, Modelling, Algo Trading, and Big Data Analysis

Slippage in Model Backtesting

A precious lesson I learned during my venture over programming an independent backtesting engine for new trading model was slippage. Simply speaking, slippage is a fraction of stock price which you need to assume as a deviation from the price you are willing to pay. In model backtesting the slippage is extremely important. Why? Let’s imagine your model generates a signal to buy or sell a stock on a day $t_i$, i.e. after when the market has been closed and your stock trading history has been updated with a stock close price. Since you can’t buy/sell this stock on day $t_i$, your algo-trading system in connection to your model rules places a new order to be executed on day $t_{i+1}$. Regardless of the position the stock holds, you don’t know the price on the following day at the opening of the market. Well, in real-time trading – yes. However, in the backtesting of your model this information is available, e.g. your have historical stock prices of IBM in Aug 2008, so you know the future.

Now, you may wish to program your backtesting engine to buy/sell this stock for you on $t_{i+1}$ day at the open, mid-day, intra-day, or even close price. The choice is yours. There are different strategies. Close price is good option for consideration as long as you have also an track of intra-day trading on $t_{i+1}$, therefore you have time to analyze the intra-day variability, take extra correction for extreme volatility or black-swans, and proceed with your order with extra caution. But if you program a simple approach in your order execution (e.g. buy at open price) you assume some risk of the price not to be in your favour.

Quite conservative approach to compensate for systematic unexpected slippages in the stock price when your order has been sent to the broker is to assume in simulations (backtesting) a fixed slippage working against your profits every time. Namely, you don’t buy/sell your stock at the price as given on $t_{i+1}$ day in your historical price table. You assume the slippage of $\Delta S$. If the price of the stock is $P$ your slippage affects the price:
P’ = P \pm (P\times \Delta S)
$$ where $P’$ is the executed price for your simulated order. The sign $\pm$ has double meaning. To allow you to understand it, let me draw two basic rules of the slippage in backtesting:


If your trading decision is to go long you always buy at the price higher by $P\times \Delta S$ than P and you sell the stock at the price lower than $P$, again by $P\times \Delta S$. Reversely, if you open a short position, you buy lower and sell higher when closing the same position.

The amount of slippage you should assume varies depending on the different conditions. If you are involved in lots of algorithmic trading operations, you probably are able to estimate your slippage. In general, the simulated slippage shouldn’t be more than 2%.

If you forget to include the slippage in your backtesting black-box, it may occur that your model is extremely profitable and you risk a lot in practice. On the other hand, adding slippage to your test may make your day less bright as it has started. But don’t worry. Keep smiling as a new day is a new opportunity, and life is not about avoiding the risks but managing them right.

Contact Form Powered By : XYZScripts.com