MicroExchange Research Paper
This paper accompanies the MicroExchange project — a complete Central Limit Order Book (CLOB) matching engine with market data infrastructure and microstructure analytics. We present the theoretical foundations underlying the system's design: price formation through information aggregation (Glosten-Milgrom, Kyle), inventory-based quoting (Ho-Stoll, Avellaneda-Stoikov), and the emergence of stylized facts from order flow dynamics. We then report the analytics the zero-intelligence (ZI) simulation actually produces and contrast them with empirical equity benchmarks. The simulation reproduces volatility clustering — autocorrelation of |returns| ≈ 0.24 on 1-second bars, inside the empirical 0.15–0.40 range — generated by Hawkes self-exciting arrivals. Because the agents are uninformed, however, order flow carries no permanent price impact: both the Huang-Stoll decomposition and Kyle's λ correctly report adverse selection ≈ 0, versus the 50–70% observed in real large-cap equities. We argue this gap is itself instructive — it isolates informed trading as the missing ingredient for realistic adverse selection — and identify it as the principal extension. All figures below are deterministic and reproducible from output/report.txt.
Market microstructure studies how trading mechanisms — order types, matching rules, information asymmetry — determine transaction prices, liquidity, and market quality. This project bridges systems engineering (exchange-grade matching engine), financial economics (spread decomposition, adverse selection), and quantitative research (stylized fact reproduction, structural parameter estimation).
The CLOB organizes orders by price and time. Price priority ensures better-priced orders execute first; time priority (FIFO) ensures earlier arrivals at the same price execute first. Our engine enforces three formal invariants: (1) no crossed book, (2) FIFO preservation, (3) determinism — verified by property-based testing across 100K+ random event sequences.
The bid-ask spread compensates for order processing, inventory risk, and adverse selection (Stoll, 1989). Following Huang-Stoll (1997) we decompose the effective spread into a realized-spread component (market-maker revenue after a 5-second reversion window) and a price-impact component, enforcing the identity effective = realized + impact via consistent signing. On a one-hour AAPL run (590,168 orders, 209,905 trades) we measure, in ticks: quoted 1.06, effective 0.77, realized 0.83, price impact −0.06 — an adverse-selection ratio of ≈ −7.5%, i.e. effectively zero. The slightly negative impact reflects post-trade mean reversion (bid-ask bounce), not information: with zero-intelligence flow there is no informed counterparty, so the permanent-impact term vanishes. This is the expected result for the model, and it contrasts deliberately with the 50–70% adverse selection of real large-cap equities, where part of the flow is informed.
Kyle (1985) established ΔP = λ · ΔX. We estimate λ by OLS on 5-second buckets of signed order flow against midprice changes. On the same run we obtain λ = 1.6×10⁻⁵ ticks/share (t = 3.1) with R² = 0.01 over N = 719 intervals: order flow is weakly but statistically significantly related to price, yet explains only ~1% of its variation. This near-zero explanatory power is consistent with the ≈0 adverse selection of §3 and is exactly what theory predicts when flow is uninformed — Kyle's λ scales with the variance of fundamental information, which is absent in a ZI market. Recovering a realistic λ (Hasbrouck's 20–40% R² range, 2007) requires an informed-trader process; see §6.
Stylized facts must be measured on returns sampled at a fixed frequency (Cont, 2001). Sampling the integer-tick midprice on every event produces a series that is ~99% exact zeros and a spurious excess kurtosis of ~78; we therefore sample the midprice on fixed 1-second bars and take log returns. On that basis the simulation reproduces volatility clustering — autocorrelation of |returns| of 0.24 at lag 1, decaying to 0.06 (lag 5) and 0.04 (lag 10), inside the empirical 0.15–0.40 band — generated endogenously by the Hawkes self-exciting arrival process. Excess kurtosis is a mild 1.16: fat tails are present but far thinner than intraday equities (8–15), because the ZI midprice is tightly contained (a ~15-tick range over the hour). Recovering heavy tails requires informed or trending flow, or an exogenous fundamental-value process.
The simulation's central limitation is the absence of informed traders: zero-intelligence agents quote symmetrically around the prevailing mid and carry no private signal, so (i) adverse selection and Kyle's λ are ≈0 by construction, and (ii) the midprice is tightly contained, suppressing heavy tails. Further limitations: a single asset; no latency heterogeneity across agents; approximate cancellation (agents do not track their own resting orders, so cancel rates are estimates); no exogenous fundamental-value process; and an order book backed by std::map rather than the contiguous tick-indexed array a production engine would use. The most informative extension is a Glosten-Milgrom informed-trader population, which would jointly raise adverse selection, Kyle's λ, and return kurtosis toward empirical values — and serve as a clean test that the analytics respond correctly to the presence of information.
- Avellaneda & Stoikov (2008). High-frequency trading in a limit order book.
- Bouchaud et al. (2018). Trades, Quotes and Prices.
- Cont (2001). Empirical properties of asset returns.
- Cont, Kukanov & Stoikov (2014). The price impact of order book events.
- Glosten & Milgrom (1985). Bid, ask and transaction prices.
- Hasbrouck (2007). Empirical Market Microstructure.
- Ho & Stoll (1981). Optimal dealer pricing.
- Kyle (1985). Continuous auctions and insider trading.
- Stoll (1989). Inferring the components of the bid-ask spread.