# Backtesting using microstructure (orderbook) data

I would like to use tick data (especially order book data; but also trade) to backtest my strategies, can anyone offer a recommendation? Personally, I've written my own backtesting scripts couple of times, and also tried out backtrader. I'm aware of other Python backtesting tools out there, but typically they deal with OHLC data only.

I'm also aware of backtrader's Data Replay feature. Ideally, however, I would like to use actual order book data instead of simulated activity to analyse if we were able to execute the trade. In essence, my intended strategy is bordering slightly on cross-exchange arb/hedging execution—thus ability to execute in a timely fashion is quite critical.

From looking at other posts, I also understand that a couple other ways to deal with this include:

1. Simulating order flow distribution or model transaction costs (both based on historical data).
2. Using an OHLC backtester, but applied at a very minute interval (e.g. tick level). In this event however we are limited only to prices at the top of the order book (L1 data) and cannot evaluate our strategy properly?

I personally view these as next-best alternatives compared to backtesting with actual order book data. For those who have had experience in this aspect, do you mind sharing more on the steps you took to backtest your strategies? Or potentially suggestions that I may be blind to?

Thank you very much in advance!

I would suggest Metatrader or cTrader for testing trades (cTrader far better for data availability already in the platform). For the order book part I have no experience on that, so I don't really want to speculate about it.

In order to test your strategies you will have to write them in mql4 / 5 regarding Metatrader or in cAlgo to be able to use them in cTrader

This question is more concerned with a high frequency TAQ-like data source than a backtesting engine (which you can write your own when you have data).

In the book Trades, Quotes and Prices, the authors use the LOBSTERS limit order book academic dataset. They even offer a sample dataset with the book and 10 levels bids and asks are provided. You do have to pay for it if you want access. But the price is significantly cheaper than a commercial vendor like Exegy (it sounds to me that you are an academic user).

Otherwise, I am aware of Polygon.io. They offer trade and quote data too on a monthly subscription basis. But I have never used them before. From feedback, I think they are doing a very good job.