Quoted, effective, and realized spreads as microstructure state variables. Decomposing the cost of immediacy for execution models.
The bid-ask spread is far more than a simple transaction cost — it is a compressed summary of inventory risk, adverse selection, and market-maker expectations about future order flow. This paper formalizes quoted, effective, and realized spreads as microstructure state variables and provides a Python implementation for decomposing the cost of immediacy in execution models.
At the surface, the bid-ask spread looks trivial. But in market microstructure, the spread is not merely a transaction cost — it is a compressed summary of inventory risk, adverse selection, tick-size constraints, queue competition, and market-maker expectations about future order flow.
The effective spread measures how far the trade price deviates from the midpoint, adjusted for trade direction (\(D_t = +1\) for buyer-initiated, \(D_t = -1\) for seller-initiated):
The realized spread compares the execution price to a later midpoint \(M_{t+\Delta}\), showing ex-post dealer revenue net of information effects:
import pandas as pd import numpy as np def compute_spreads(df: pd.DataFrame, horizon=5) -> pd.DataFrame: out = df.copy() out["mid"] = (out["bid"] + out["ask"]) / 2 out["quoted_spread"] = out["ask"] - out["bid"] out["effective_spread"] = 2 * out["trade_sign"] * (out["trade_price"] - out["mid"]) out["mid_future"] = out["mid"].shift(-horizon) out["realized_spread"] = 2 * out["trade_sign"] * (out["trade_price"] - out["mid_future"]) out["price_impact"] = out["effective_spread"] - out["realized_spread"] return out
Spread behavior is endogenous — it reflects the interaction between the limit order book and expected future price movement. This is why microstructure-aware models often include spread, queue position, depth imbalance, cancellation rates, and order flow imbalance together rather than in isolation. The spread is the market's local price of immediacy.