I am looking to estimate the realized spread defined as $$\text{realized spread} = 2D_k(ln(P_k) - ln(M_{k+5}))$$

Where $$D_k$$ is 1 for buy transactions and -1 for sell transactions.

$$P_k$$ is the price at which the transaction executed and $$M_{k+5}$$ is the midpoint (average of bid and ask quotes) five minutes later.

I have a series of transaction data with the time of the execution, the price of execution, whether it was buyer or seller initiated, the volume, and whether it was a limit or a market order.

I am familiar with this question and the papers mentioned.

However, the techniques there refer to estimating the effective spread $$2D_k(ln(P_k) - ln(M_{k}))$$, notice the midpoint is at the same time as the transaction.

I would appreciate any guidance or reference.