Level 5 — MasteryMarket Microstructure

Market Microstructure

90 minutes60 marksprintable — key stays hidden on paper

Chapter: 6.3 Market Microstructure Level: 5 — Mastery (cross-domain: probability/math + coding + proof/derivation) Time limit: 90 minutes Total marks: 60

Instructions. Answer all three questions. Show all derivations. Where code is requested, write clean pseudocode or Python. Use ...... notation for mathematics. State every assumption.


Question 1 — Price Impact & Limit Order Book Depth (20 marks)

A limit order book (LOB) for a stock has a discrete price grid with tick size \delta = \0.01.Ontheaskside,therestingquantityavailableatthe. On the **ask side**, the resting quantity available at the k$-th price level above the best ask is

qk=Q0eλk,k=0,1,2,q_k = Q_0\, e^{-\lambda k}, \qquad k = 0,1,2,\dots

where the best ask is at price a_0 = \100.00,level, level ksitsatpricesits at pricea_k = a_0 + k\delta,, Q_0 = 5000shares,andshares, and\lambda = 0.20$.

A market buy order of size MM shares "walks the book," consuming levels from k=0k=0 upward.

(a) Derive a closed-form expression for the cumulative depth D(n)=k=0nqkD(n) = \sum_{k=0}^{n} q_k available through level nn, and hence the minimum number of levels n\*n^\* that must be swept to fill an order of M=12000M = 12000 shares. (6)

(b) Define the volume-weighted average execution price (VWAP) of the marketable buy order of size MM as

Pexec(M)=1Mk=0n\*akxk,P_{\text{exec}}(M) = \frac{1}{M}\sum_{k=0}^{n^\*} a_k\, x_k,

where xkx_k is the quantity taken from level kk (with xn\*x_{n^\*} possibly partial). Derive the price impact I(M)=Pexec(M)a0I(M) = P_{\text{exec}}(M) - a_0 as an explicit function, and evaluate it numerically for M=12000M=12000. (8)

(c) In the continuous-depth limit (δ0\delta \to 0, density ρ(p)=(Q0/δ)eλ(pa0)/δ\rho(p) = (Q_0/\delta)\,e^{-\lambda (p-a_0)/\delta} shares per dollar), show that price impact grows approximately as I(M)ln()I(M)\propto \ln(\cdot) or a power law of MM for small MM, and identify the regime. Comment on what this implies about market depth as a liquidity measure. (6)


Question 2 — Bid–Ask Spread Decomposition & Adverse Selection (22 marks)

Adopt a Glosten–Milgrom-style single-trade model. A market maker (MM) quotes a bid BB and ask AA around an unknown true value VV. With probability π\pi the incoming trader is informed (knows VV), and with probability 1π1-\pi is a noise trader who buys or sells with equal probability 12\tfrac12. The prior distribution of VV is: V=VHV = V_H (high) or V=VLV = V_L (low), each with prior probability 12\tfrac12. Let μ=12(VH+VL)\mu = \tfrac12(V_H+V_L) and Δ=VHVL>0\Delta = V_H - V_L > 0.

(a) Using Bayes' theorem, show that the competitive (zero-expected-profit) ask price equals the expected value of VV conditional on a buy order arriving:

A=E[Vbuy].A = \mathbb{E}[V \mid \text{buy}].

Derive AA explicitly in terms of π\pi, μ\mu, and Δ\Delta. (8)

(b) By symmetry derive the bid B=E[Vsell]B = \mathbb{E}[V\mid\text{sell}], and hence show the adverse-selection component of the spread is

Sadv=AB=2πΔ1+π122    (simplify to closed form).S_{\text{adv}} = A - B = \frac{2\pi\,\Delta}{1+\pi}\cdot\frac{1}{2}\cdot 2 \;\; \text{(simplify to closed form).}

Evaluate SadvS_{\text{adv}} for π=0.30\pi = 0.30, \Delta = \2.00.Provethat. Prove that \partial S_{\text{adv}}/\partial \pi > 0$ and interpret. (8)

(c) Real spreads also contain an order-processing component cc (per share, fixed) and an inventory component. Suppose the MM adds a symmetric processing charge c=\0.02.Writetheobservedhalfspreadandfullspread.Thendesignashortalgorithm(pseudocode)thatestimates. Write the observed half-spread and full spread. Then design a **short algorithm** (pseudocode) that estimates \pifromastreamoftradesandmidpricerevisions,usingthefactthattheposttrademidpointrevisionafterabuyequalsfrom a stream of trades and mid-price revisions, using the fact that the post-trade midpoint revision after a buy equalsA - \mu_{\text{prior}}$. State clearly the estimator and one source of bias. (6)


Question 3 — Iceberg Orders, Latency & a Detection Simulation (18 marks)

A trader posts an iceberg (hidden) order at the best bid: total size T=100,000T = 100{,}000 shares, displayed peak v=2,000v = 2{,}000 shares. Each time the displayed peak is fully executed, a new peak of vv shares is automatically reposted at the same price with a fresh time-priority timestamp; hidden reserve replenishes until exhausted.

(a) A competing latency-arbitrage bot observes each fill at the bid. Model detection: the bot infers a hidden order is present if it observes rr consecutive immediate re-displays of size exactly vv at the same price with no price move. If any single "innocent" (non-iceberg) reload occurs with probability p=0.15p=0.15 per event independently, compute the probability of a false positive for a detection threshold of r=4r=4, and choose the smallest rr giving false-positive probability below 1%1\%. (6)

(b) The bot sits in a co-location rack with round-trip latency co=40μs\ell_{\text{co}} = 40\,\mu s; a remote competitor has rem=900μs\ell_{\text{rem}} = 900\,\mu s. A new displayed peak lasts on average τ=500μs\tau = 500\,\mu s before being hit. Explain quantitatively which participant can reliably react within the peak's lifetime, and compute the latency advantage margin (as a fraction of τ\tau) enjoyed by the co-located bot. (4)

(c) Write a simulation (Python-style pseudocode) that, given the fill stream, (i) reconstructs how many iceberg reloads occurred, (ii) estimates total hidden size TT, and (iii) outputs the fraction of TT that was never displayed. Then compute that hidden fraction for the given numbers and comment on the microstructure trade-off between information leakage and execution speed for iceberg orders. (8)


End of paper.

Answer keyMark scheme & solutions

Question 1

(a) Cumulative depth (6)

Geometric series:

D(n)=k=0nQ0eλk=Q01eλ(n+1)1eλ.(3)D(n)=\sum_{k=0}^{n}Q_0 e^{-\lambda k}=Q_0\frac{1-e^{-\lambda(n+1)}}{1-e^{-\lambda}}. \quad(3)

Total book depth as nn\to\infty: D()=Q0/(1eλ)D(\infty)=Q_0/(1-e^{-\lambda}). With Q0=5000, λ=0.2Q_0=5000,\ \lambda=0.2: 1e0.2=0.1812691-e^{-0.2}=0.181269, so D()=27,584D(\infty)=27{,}584 shares (>12000, so fillable).

Solve D(n)M=12000D(n)\ge M=12000: 1e0.2(n+1)M(1eλ)/Q0=12000(0.181269)/5000=0.4350461-e^{-0.2(n+1)}\ge M(1-e^{-\lambda})/Q_0 = 12000(0.181269)/5000=0.435046. e0.2(n+1)0.5649540.2(n+1)ln0.564954=0.571015e^{-0.2(n+1)}\le 0.564954 \Rightarrow -0.2(n+1)\le\ln0.564954=-0.571015 n+12.855n1.855n\*=2.\Rightarrow n+1\ge 2.855 \Rightarrow n\ge1.855 \Rightarrow n^\*=2. (3) (Levels k=0,1,2k=0,1,2 are swept, with k=2k=2 partial.)

(b) Price impact / VWAP (8)

Full levels k=0,1k=0,1 give D(1)=Q0(1+e0.2)=5000(1.818731)=9093.65D(1)=Q_0(1+e^{-0.2})=5000(1.818731)=9093.65 shares (round: use exact). Cumulative:

  • q0=5000q_0=5000, q1=5000e0.2=4093.65q_1=5000e^{-0.2}=4093.65, D(1)=9093.65D(1)=9093.65.
  • Remaining to fill at k=2k=2: x2=MD(1)=120009093.65=2906.35x_2 = M - D(1)=12000-9093.65=2906.35 shares. (Full q2=5000e0.4=3351.60q_2=5000e^{-0.4}=3351.60, so partial — consistent.) (2)

Cost:

Cost=akxk=a0x0+a1x1+a2x2,\text{Cost}=\sum a_k x_k = a_0 x_0 + a_1 x_1 + a_2 x_2,

with ak=100+0.01ka_k=100+0.01k. =100(5000)+100.01(4093.65)+100.02(2906.35)=100(5000)+100.01(4093.65)+100.02(2906.35) =500000+409406.9+290693.1=500000+409406.9+290693.1... compute precisely:

  • 100.01×4093.65=409406.94100.01\times4093.65=409406.94
  • 100.02×2906.35=290693.13100.02\times2906.35=290693.13
  • Sum =1,200,100.07=1{,}200{,}100.07. (2)

Pexec=1,200,100.07/12000=100.008339P_{\text{exec}}=1{,}200{,}100.07/12000=100.008339.

I(M)=Pexeca0=$0.0083390.83 cents.(2)I(M)=P_{\text{exec}}-a_0=\$0.008339\approx0.83\text{ cents}. \quad(2)

Closed form: I(M)=δkkxkMI(M)=\delta\cdot\dfrac{\sum_k k\,x_k}{M} = tick times the volume-weighted average level index. Here weighted level =I/δ=0.8339=I/\delta=0.8339. (2)

(c) Continuous limit & interpretation (6)

Continuous depth density with exponential decay: to fill MM shares, sweep price up to p\*p^\* where

M=a0p\*ρ(p)dp=Q0λδ(1eλ(p\*a0)/δ).M=\int_{a_0}^{p^\*}\rho(p)\,dp=\frac{Q_0}{\lambda\delta}\Big(1-e^{-\lambda(p^\*-a_0)/\delta}\Big).

Let u=(p\*a0)u=(p^\*-a_0). Then eλu/δ=1λδMQ0e^{-\lambda u/\delta}=1-\frac{\lambda\delta M}{Q_0}, so

p\*a0=δλln ⁣(1λδMQ0).(2)p^\*-a_0=-\frac{\delta}{\lambda}\ln\!\Big(1-\frac{\lambda\delta M}{Q_0}\Big). \quad(2)

For small MM (i.e. λδM/Q01\lambda\delta M/Q_0\ll1): expand ln(1ϵ)ϵ+ϵ2/2-\ln(1-\epsilon)\approx\epsilon+\epsilon^2/2, giving

p\*a0δMQ0(1+12λδMQ0),p^\*-a_0\approx \frac{\delta M}{Q_0}\Big(1+\tfrac12\frac{\lambda\delta M}{Q_0}\Big),

so the marginal impact is linear then convex; the average impact I(M)=12(p\*a0)I(M)=\tfrac12(p^\*-a_0) to leading order δM/(2Q0)\approx \delta M/(2Q_0), i.e. linear in MM for small orders (linear-impact regime), becoming logarithmically divergent as MQ0/(λδ)M\to Q_0/(\lambda\delta) (book near exhaustion). (2)

Interpretation: market depth Q0/λ\approx Q_0/\lambda (or the coefficient Q0/(λδ)Q_0/(\lambda\delta)) is the reciprocal of the linear price-impact slope. A deeper book (larger Q0Q_0, smaller λ\lambda) yields smaller impact per share — depth and impact are inversely related; depth is a valid resiliency/liquidity measure only in the small-order linear regime, and breaks down near exhaustion. (2)


Question 2

(a) Competitive ask (8)

A "buy" is a marketable order lifting the ask. Likelihoods:

  • If V=VHV=V_H: informed traders (prob π\pi) buy for sure; noise (prob 1π1-\pi) buy w.p. 12\tfrac12. P(buyVH)=π1+(1π)12=1+π2.P(\text{buy}\mid V_H)=\pi\cdot1+(1-\pi)\cdot\tfrac12=\tfrac{1+\pi}{2}.
  • If V=VLV=V_L: informed sell (never buy); noise buy w.p. 12\tfrac12. P(buyVL)=π0+(1π)12=1π2.P(\text{buy}\mid V_L)=\pi\cdot0+(1-\pi)\cdot\tfrac12=\tfrac{1-\pi}{2}. (3)

Posterior after a buy (equal priors 12\tfrac12):

P(VHbuy)=121+π2121+π2+121π2=1+π2.P(V_H\mid\text{buy})=\frac{\tfrac12\cdot\frac{1+\pi}{2}}{\tfrac12\cdot\frac{1+\pi}{2}+\tfrac12\cdot\frac{1-\pi}{2}}=\frac{1+\pi}{2}.

(Denominator =12=\tfrac12.) (2) Zero-profit competitive ask:

A=E[Vbuy]=1+π2VH+1π2VL=μ+π2Δ.(3)A=\mathbb E[V\mid\text{buy}]=\frac{1+\pi}{2}V_H+\frac{1-\pi}{2}V_L=\mu+\frac{\pi}{2}\Delta. \quad(3)

(b) Bid, spread, monotonicity (8)

By symmetry P(VHsell)=1π2P(V_H\mid\text{sell})=\frac{1-\pi}{2}, so

B=E[Vsell]=1π2VH+1+π2VL=μπ2Δ.(3)B=\mathbb E[V\mid\text{sell}]=\frac{1-\pi}{2}V_H+\frac{1+\pi}{2}V_L=\mu-\frac{\pi}{2}\Delta. \quad(3)

Adverse-selection spread:

Sadv=AB=πΔ.(2)S_{\text{adv}}=A-B=\pi\Delta. \quad(2)

(The messy form in the paper simplifies to this clean result.) Numeric: \pi=0.30,\Delta=2 \Rightarrow S_{\text{adv}}=0.30\times2=\0.60.(1)**(1)**\partial S_{\text{adv}}/\partial\pi=\Delta=2>0$: strictly increasing. Interpretation: more informed flow ⇒ MM faces greater adverse selection ⇒ must widen the spread to break even; spread is pure compensation for expected losses to better-informed counterparties. (2)

(c) Full spread + estimator (6)

Observed quotes add symmetric processing charge cc: Aobs=μ+πΔ2+cA_{\text{obs}}=\mu+\tfrac{\pi\Delta}{2}+c, Bobs=μπΔ2cB_{\text{obs}}=\mu-\tfrac{\pi\Delta}{2}-c. Half-spread =πΔ2+c=\tfrac{\pi\Delta}{2}+c; full spread =\pi\Delta+2c=0.60+0.04=\0.64.$ (2)

Estimator idea: post-trade midpoint revision after a buy is Aμ=πΔ2A-\mu=\tfrac{\pi\Delta}{2}; after a sell μB=πΔ2\mu-B=\tfrac{\pi\Delta}{2}. So average absolute mid-revision r^=πΔ2^\hat r=\widehat{\tfrac{\pi\Delta}{2}}, giving π^=2r^/Δ\hat\pi=2\hat r/\Delta (with Δ\Delta estimated from realized value moves or long-run price variance). (3)

def estimate_pi(trades, Delta):
    # trades: list of (sign, mid_before, mid_after), sign=+1 buy,-1 sell
    revisions = [sign*(mid_after - mid_before)
                 for (sign, mid_before, mid_after) in trades]
    r_hat = mean(revisions)          # = pi*Delta/2 in expectation
    return 2*r_hat/Delta

One source of bias: inventory-driven quote skew and order-processing cost cc contaminate the mid-revision (transitory bounce), so naive r^\hat r overstates the permanent adverse-selection component unless one uses long-horizon (permanent) price impact rather than the immediate next mid. (1)


Question 3

(a) False positive & threshold (6)

Independent innocent reloads, each prob p=0.15p=0.15. False positive at threshold rr = probability of rr consecutive innocent reloads =pr=p^r. (2) For r=4r=4: p4=0.154=0.000506250.0506%p^4=0.15^4=0.00050625\approx0.0506\%. Already <1%<1\%. (2) Smallest rr with pr<0.01p^r<0.01: rlnp<ln0.01r>ln0.01/ln0.15=4.605/1.897=2.427r=3r\ln p<\ln0.01\Rightarrow r>\ln0.01/\ln0.15=4.605/1.897=2.427\Rightarrow r=3. Check 0.153=0.003375<0.010.15^3=0.003375<0.01 ✓; 0.152=0.0225>0.010.15^2=0.0225>0.01. So smallest r=3r=3. (Given r=4r=4 has FP 0.05%\approx0.05\%.) (2)

(b) Latency (4)

Peak lifetime τ=500μs\tau=500\,\mu s.

  • Co-located bot: $\ell_{\text{co}}=40