# 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?

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.