Skip to content
All library documents

Using Market Depth to Improve Bid-Ask Backtests

Article Quant Q&A · Author: idealistikz

Summary

The document explains why a backtest based only on the best bid and best ask can overstate achievable execution quality. Those quotes represent the most favorable available prices for limited quantities; larger orders may consume that liquidity and fill at worse prices deeper in the order book. This gap contributes to implementation shortfall.

A suggested workflow is to first test a strategy with best bid and ask quotes as an optimistic baseline, then incorporate market depth and transaction costs if the strategy appears viable. The discussion warns that results based on top-of-book prices implicitly assume sufficient liquidity for every trade, so they are meaningful mainly at small sizes. It offers no empirical measurements or specific depth model, and notes that even a more detailed backtest cannot guarantee live performance, which may be worse than the simulation.

Key ideas

  • Best bid and ask quotes may cover only a limited quantity.
  • Larger orders can execute at worse prices as they consume liquidity deeper in the book.
  • Top-of-book-only backtests assume liquidity that may not be available at the strategy’s trade size.
  • A staged evaluation can begin with best quotes and then add depth and transaction costs.
  • Backtest results remain imperfect estimates of live execution.

Tags

Full text
# What are the advantages of knowing the bid and ask over the best bid and ask?


# What are the advantages of knowing the bid and ask over the best bid and ask?












I am importing historical intraday tick data from Bloomberg and I noticed the Bloomberg API allows users to import best bid, best ask, bid, and ask prices

If I am backtesting a trading strategy, what advantages would having the bid and ask prices provide over the best bid and ask prices?

## Answer by SRKX (score 4, accepted)

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

As explained in the comments best bid and best offer (best ask) are the best prices at which you can respectively sell and buy at least one unit of the asset your are considering.

When backtesting a strategy, most people usually either use best bid and best offer or even worse last price.

The problem is that these prices are only available for a limited amount of units. Therefore if you start trading a substantive amount of lots, you might not have enough liquidity in the market (i.e. enough units available at best bid/offer), and you would then trade at a prices which is not as good as the one provided by the best bid/offer. This is all part of the implementation shortfall.

So, if you use best bid/offer prices for your backtest, you have to keep in mind that the result you get did not take into account the size of your trades and hence that the results are only significant for a small size; you always assume full liquidity and hence the best price possible for each and every trade. This is not a very realistic scenario, even more when you consider that the smaller the size, the larger the transaction costs in relative terms.

In general, you should first perform your backtest using best price/offer to see if your strategy is profitable in the best scenario. If you're happy with that, you can carry on taking into account the market depth (bid and ask beyond the best) and transaction costs. Anyway, backtest is never perfect and you should expect that a live execution of the strategy would not perform the same, and most of the time not as well as in the simulation.

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.