Market-Making Backtests: Historical Replay and Queue-Reactive Simulation
Summary
The document explores how to backtest an Avellaneda–Stoikov style market-making strategy using historical limit order book data. The question describes estimating order-arrival intensities from synchronized order and book events, then asks how simulated quotes, reference prices, and executions should relate to the recorded market. It contrasts simulating quote processes with modeling inventory and cash changes from executions.
The response stresses that high-frequency backtests must account for the strategy’s effect on the market and avoid granting unrealistic fills. In historical replay, passive and aggressive orders need consistent execution rules: an order should not consume the same displayed liquidity repeatedly, and the simulated book needs recovery time. A queue-reactive model is offered as an alternative when departing from historical paths, particularly for stress testing. The cited work is presented as a source for simulation details, but the document gives no implementation, calibration results, or quantitative comparison. These approaches therefore describe modeling choices, not proof that a backtest will predict live performance.
Key ideas
- High-frequency market-making backtests must account for the effect of simulated orders on market liquidity.
- Historical replay should prevent simulated orders from consuming the same liquidity repeatedly.
- A recovery period can help represent how the recorded order book replenishes after executions.
- Queue-reactive models can move beyond observed paths and are suggested mainly for stress testing.
- The discussion gives modeling guidance but no measured strategy results.
Tags
Full text
# Understanding the calibration of High-frequency trading in a limit order book
# Understanding the calibration of High-frequency trading in a limit order book
I am trying understand and replicate this thesis, which is based on, High-frequency trading in a limit order book by (Avellaneda and Stoikov, 2008) and Optimal market making, by Olivier Gueant, 2017, except the thesis uses real historical data to calculate the intensities and uses best bid(ask) as the reference price when calculating the intensities $\lambda^a$($\lambda^b$), whilst Avellaneda uses the mid-price.
I currently have a full-day, 10 level limit order book with $0.1$ second increments. I also have the order info such as hidden order, cancellation, MO buy/sell, LO placed etc with the same increments in-sync.
Therefore, I can calculate intensities $\lambda_t = \Lambda(\delta_t)$, and solve for $A$ and $k$ in $\Lambda(\delta_t)=Ae^{-k\delta}$, during the time period of the LOB data. As well as the $\sigma$ (assuming constant volatility for now).
Main question: How is the back-test actually conducted?
From what I understand, the bid and ask price are simulated using:
$$\begin{align} dS_t^b & = \sigma S_t^bdW_t^b \\ dS_t^a & = \sigma S_t^a dW_t^a \end{align}$$
and $$\begin{align} \delta_t^b & = S_t - S_t^b \\ \delta_t^a & = S_t^a - S_t,\end{align}$$
where $S_t$ is the reference price.
And the MM cash account is modelled by:
$$ d X_t=\left(S_t+\delta^a\right) d N_t^a-\left(S_t-\delta^b\right) d N_t^b $$
where $N_t$ is a poisson distribution with the intensity $\lambda_t$, which is calculated from the historical dataset I have.
My confusion lies in their algorithm and simulation. If they simulate the ask and bid price, it obviously won’t follow the fluctuations of the bid-ask spread in the dataset. I.e. if $S_0 = 100$ and $S_3 = 80$ from the simulation, but what if the level 1 bid-ask price is $S_3=101$ and $S_3=103$?
From algorithm 1 on page 74 of the thesis, it seems that they calculate $\delta^a$ and $\delta^b$ at $t=0$, with starting buy and sell positions in the order book of $LO^a$ and $LO^b$. Then they simulate $S_t^a$ and $S_t^b$ and if the simulated bid-asks meet their orders, then it’s executed.
I am not sure how this simulation process is happening. And if we are simulating, $S_t^a$ and $S_t^b$, what happens if $S_t^a<S_t^b$?
Whilst in the Avellaneda and Stoikov paper, they only simulate the mid-price and then use the intensities as to whether the MM wealth changes.
Or is only $d X_t=(S_t+\delta^a) d N_t^a - …$ simulated using the parameters we calculated from the historical LOB data?
Some insights would be greatly appreciated.
## Answer by lehalle (score 2)
https://quant.stackexchange.com/a/79438
Back testing at high frequency is complicated. First because it involves a lot of data, then because at this time scale you are sure that your (simulated) orders will have a feedback effect and influence other participants.
First, have a look at quant.stackexchange, for instance:
- Backtesting Market Making Strategy or Microstructure Strategy
- Standard ways of simulating order books
- and Limit Order Book modeling for technical/pythonic aspects.
For the specific aspect of simulating the Avellaneda-Stoikov paper, I would recommend to have a look at Guéant, Olivier, L, and Joaquin Fernandez-Tapia. "Dealing with the inventory risk: a solution to the market making problem." Mathematics and financial economics 7 (2013): 477-507. It generalises the former paper and it has a full section on simulations.
If I can summary
- if you want to stay lose to the historical recordings, you nevertheless need to be careful to be sure that one of your passive orders does not get too much executions your aggressive orders (yet it is possible that the solution of this market making problem ends up with marketable orders) should not be able to consume the same limit order more than once, and respect a "recovery time" of the orderbook.
- if you accept to go away from the historical records, the Queue Reactive Model is a good solution, but be careful: it is mainly useful for stress-test.
It provides you 2 "regimes": one close to historical data to assess what will happen if you do not perturb ate too much the liquidity regime of the recorded days, and the other to stress test your strategy.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.