Asset Classes

Free investment financial education

Language

Multilingual content from IBKR

Close Navigation
Learn more about IBKR accounts
Slippage in Model Backtesting

Slippage in Model Backtesting

Posted July 14, 2023 at 9:58 am

Dr. Pawel Lachowicz
Quant at Risk

A precious lesson I learned during my venture over programming an independent backtesting engine for new trading model was slippage. A feature that cannot be easily neglected and can blur the ultimate profit profile.

What is 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 ti, 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 ti, your algo-trading system in connection to your model rules places a new order to be executed on day ti+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. you have historical stock prices of IBM in Aug 2008, so you know the future.

Slippage in Backtesing

Now, you may wish to program your backtesting engine to buy/sell this stock for you on ti+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 a track of intra-day trading on ti+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 ti+1 day in your historical price table. You assume the slippage of ΔS. If the price of the stock is P your slippage affects the price:

where P′ is the executed price for your simulated order. The sign ± 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 × ΔS than P and you sell the stock at the price lower than P, again by P × Δ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%. One allows for higher values but this becomes useful for less liquid assets in trading.

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 it 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.

Originally posted on Quant at Risk.

Join The Conversation

If you have a general question, it may already be covered in our FAQs. If you have an account-specific question or concern, please reach out to Client Services.

Leave a Reply

Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from Quant at Risk and is being posted with its permission. The views expressed in this material are solely those of the author and/or Quant at Risk and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

IBKR Campus Newsletters

This website uses cookies to collect usage information in order to offer a better browsing experience. By browsing this site or by clicking on the "ACCEPT COOKIES" button you accept our Cookie Policy.