Skip to content
All library documents

Bid–Ask Spreads and Execution Assumptions in Backtests

Article Quant Q&A · Author: brownie74

Summary

This discussion considers whether a candle-based strategy backtest can rely on mid-prices, especially when modeling stop losses, or should use bid and ask prices to reflect the side at which a trade executes. The author reports that replacing mid-price highs and lows with side-specific bid or ask data made results much worse, while wondering whether the change exposed code errors. The question also weighs backtest simplicity against realistic execution modeling and forward testing.

The answer recommends comparing results under mid-price assumptions with results that include observed or historical bid–ask spreads, then stress-testing with wider spreads. Its example describes a frequently traded credit-default-swap strategy that appeared profitable at mid but lost money after an assumed spread was included; the stated spread was characterized as optimistic. This illustrates how transaction costs can reverse a backtest’s conclusion. The exchange does not give a general execution simulator, address other costs or intrabar data limitations, or determine whether the original strategy’s degraded results came from a bug. It supports treating execution assumptions as a sensitivity to examine.

Key ideas

  • Mid-price backtests can overstate performance when trades cross the bid–ask spread.
  • Stops and other execution rules may depend on the relevant bid or ask price.
  • Compare mid-price results with results using observed or historical spreads.
  • Stress-test strategies with wider spreads because costs can change their apparent profitability.

Tags

Full text
# Backtest with mid-quotes?


# Backtest with mid-quotes?












I have built a trading strategy and also a backtest. The backtest has been a lot of work. I was using mid-prices throughout. It’s based on candles, so I make trading decisions at the end of each bar. Recently I changed it to use the bid and ask. So for example to decide if a trade was stopped out I now use the bid/ask high or low (depending if I’m long or short) of the previous bar, rather than the mid high/low. Now, I’m getting much worse test results. It’s possible that due to complicating the backtest code i have introduced bugs. I am wondering if others are backtesting based on mid rates, and then do a forward test as the main stop/go flag. Intuitively I am thinking that I don’t want to have too much code in the backtest to keep it simple, then do most testing in the forward test. But on the other hand I don’t want a useless backtest since I intend to use it to develop new trading strategies quickly. Have others implemented full stop loss management in their backtests, or is this over complicating it? Have you made simplifications such as using mid-rates rather than bid/ask everywhere?

## Answer by Dimitri Vulis (score 2)

https://quant.stackexchange.com/a/69349

I once did a backtest of a very interesting strategy that involved frequently (every few days) trading credit default swaps. If I assumed that I could execute at mid, then the strategy made decent returns. However if I assumed 5 bps bid-ask spread (i.e. only 2.5 bps above and below the mid - somewhat optimistic), then the strategy lost money.

My advice to you is to look at both what your strategy would do if you could execute at mid, and also what it would do if you included the bid-ask spreads that you observe now, or have history for. Further, a stress-test assuming much wider bid-ask is always a good practice.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.