Skip to content

    Under active development. New calculators and features ship every week. Everything currently runs free while the site matures — pricing pages are a preview, checkout is not open yet.

    Finance / High-frequency microstructure signals: microprice, Kyle, Roll, realized variance

    Market Microstructure Calculator — Microprice & Order Imbalance

    Compute market microstructure signals: top-of-book microprice, order imbalance, Kyle price impact, Roll effective spread, and realized and bipower variation.

    ToolCalculatorExecutionIn browserCategoryFinancial
    ZorvLabs · Market microstructure

    High-Frequency Market Microstructure Analysis

    Top-of-book microprice, spread, order imbalance, Kyle price impact, Roll spread estimation, and realized-volatility diagnostics.
    How it works
    Deterministic
    No random seed; all curves derive from explicit microstructure equations.
    Mid quote
    100.272731
    M_t = (P^a + P^b)/2
    Spread
    0.045351
    S_t = P^a − P^b
    Microprice
    100.273433
    Pμ_t = weighted top-of-book
    Order imbalance
    -1.457e-17
    I_t ∈ [−1, 1]
    View mode
    3D surface
    Best bid
    Best ask
    Bid size
    Ask size
    Base mid
    Base spread
    Trade size q
    Kyle λ
    Noise level
    Tape length
    Horizon ticks
    Signature windows
    Surface X resolution
    Surface Y resolution
    Kyle impact
    1.355e-19
    Mean λq_t
    Roll spread
    0.000000
    2√(−cov₁)
    Realized variance
    8.167e-6
    Σ r_i²
    Bipower variation
    9.782e-6
    μ1⁻² Σ|r_i||r_{i−1}|
    Microprice: Pμ = (PaVb + PbVa)/(Vb + Va)
    Roll estimator: Ŝ = 2√(max(−cov(Δp_t, Δp_{t−1}), 0))
    2D tape
    Mid quote, microprice, and trade price over microstructure events
    Price tapeEvent timePrice0.063.8127.6191.4255.2319.099.9100.0100.2100.4100.5100.7MidMicropriceTrade
    2D signal stack
    Imbalance, spread, and Kyle impact
    Order-flow signal stackEvent timeSignal value0.063.8127.6191.4255.2319.0-0.8-0.5-0.20.20.50.8ImbalanceSpreadKyle impact
    2D volatility diagnostics
    Realized variance, bipower variation, and signature plot
    Accumulated variance diagnosticsEvent timeVariance0.063.8127.6191.4255.2319.00.01.956e-63.913e-65.869e-67.825e-69.782e-6RVBVSignature plotSampling windowRealized variance1.013.626.238.851.464.08.167e-62.435e-54.052e-55.670e-57.288e-58.906e-5RV by sampling window
    2D tape band
    Mid quote with 5%–95% deterministic tape envelope
    Microprice / trade envelopeEvent timePrice0.063.8127.6191.4255.2319.099.9100.0100.2100.4100.5100.7Mean signal5% / 95% band
    3D exact surface
    Microprice over bid/ask sizes
    3D microprice surface Pμ(Vb, Va)Bid sizeAsk sizePμsurface grid52 × 52 cells · max Pμ = 100.014418
    Key formulas
    Kyle · Glosten-Milgrom · Stoikov · Roll · Aït-Sahalia/Mykland/Zhang · Barndorff-Nielsen/Shephard
    Kyle (1985): linear price impact Δp_t = λ q_t + ε_t.
    Glosten & Milgrom (1985): bid-ask spread from asymmetric information.
    Stoikov-style microprice: Pμ = (PaVb + PbVa)/(Vb + Va) = M + (S/2)I.
    Roll (1984): Ŝ = 2 √(−cov(Δp_t, Δp_{t−1})) when covariance is negative.
    Aït-Sahalia, Mykland & Zhang (2005): microstructure noise implies finite optimal sampling.
    Barndorff-Nielsen & Shephard (2004): RV and BV for high-frequency volatility.
    Current snapshot: Pμ = 100.273433 | S = 0.045351 | I = -1.457e-17 | RV = 8.167e-6
    finance methodology

    A clear path from inputs to results.

    See the standard market-microstructure signals computed from a limit order book and a trade tape. The core turns best bid and ask quotes, their sizes, and order flow into the top-of-book microprice, the order imbalance, Kyle price impact, the Roll effective spread, and realized and bipower volatility. It is a reference implementation of the equations desks use to read short-horizon price pressure, so you can tie each number back to its source formula rather than a black box.

    Step-by-step methodWorked exampleAssumptions explained

    How to use

    1. Set the best bid and best ask prices and the resting sizes on each side; these define the quoted spread and the order imbalance.
    2. Set the base mid, base spread, and the trade size q used to drive the deterministic tape of microstructure events.
    3. Set the Kyle lambda, the linear price-impact coefficient that maps signed order flow into price moves.
    4. Set the noise level and the tape length to control how much microstructure noise is injected and how many events are simulated.
    5. Read the top-of-book microprice and order imbalance, the mean Kyle impact, and the Roll effective-spread estimate from the serial covariance of price changes.
    6. Read the realized variance and bipower variation, and compare them on the signature plot across sampling frequencies to see the noise-versus-bias tradeoff of high-frequency estimators.

    The formula

    Pμ=PaVb+PbVaVb+Va=M+S2 I,M=Pa+Pb2,  S=Pa−Pb,  I=Vb−VaVb+Va,Δpt=λqt+εt,S^Roll=2max⁡(−Cov(Δpt,Δpt−1), 0),RV=∑iri2,  BV=μ1−2∑i∣ri∣∣ri−1∣P^{\mu} = \frac{P^{a}V^{b} + P^{b}V^{a}}{V^{b} + V^{a}} = M + \tfrac{S}{2}\,I, \quad M = \tfrac{P^{a}+P^{b}}{2}, \; S = P^{a}-P^{b}, \; I = \frac{V^{b}-V^{a}}{V^{b}+V^{a}}, \quad \Delta p_t = \lambda q_t + \varepsilon_t, \quad \hat{S}_{\text{Roll}} = 2\sqrt{\max(-\mathrm{Cov}(\Delta p_t, \Delta p_{t-1}),\,0)}, \quad RV = \sum_i r_i^2, \; BV = \mu_1^{-2}\sum_i |r_i||r_{i-1}|

    Reference: Kyle (1985), "Continuous Auctions and Insider Trading", Econometrica 53(6); Glosten & Milgrom (1985); Roll (1984), "A Simple Implicit Measure of the Effective Bid-Ask Spread"; Barndorff-Nielsen & Shephard (2004) for realized and bipower variation; Ait-Sahalia, Mykland & Zhang (2005) for the signature plot.

    Worked example

    Top-of-book microprice from a quoted order book

    Inputs
    • Best bid 99.98 with 820 lots resting, best ask 100.02 with 760 lots resting.
    Calculation path
    1. 1

      The mid is M = (99.98 + 100.02)/2 = 100.00 and the quoted spread is S = 100.02 - 99.98 = 0.04. The order imbalance is I = (V_b - V_a)/(V_b + V_a) = (820 - 760)/(820 + 760) = 60/1580 = 0.037975, positive because the bid side is heavier. The size-weighted top-of-book microprice is P_mu = (P_a*V_b + P_b*V_a)/(V_b + V_a) = (100.02*820 + 99.98*760)/1580 = 158001.2/1580 = 100.000759. This equals the identity form M + (S/2)*I = 100 + 0.02*0.037975 = 100.000759 exactly, confirming the microprice sits above the mid by half the spread scaled by the imbalance.

    Result

    Mid 100.000000, spread 0.040000, order imbalance 0.037975, top-of-book microprice 100.000759 (0.76 ticks of a 0.04 spread above the mid, pulled toward the ask by the heavier bid side).

    Interpreting the result

    The microprice is the fair value implied by the book: when the bid size exceeds the ask size the imbalance is positive and the microprice sits above the mid, anticipating an upward move, which is why it predicts short-horizon price changes better than the mid. Kyle lambda measures how much a unit of signed order flow moves the price, so a larger lambda means a less liquid, more impactful market. The Roll estimator backs out the effective spread from the negative serial correlation that bid-ask bounce induces in trade prices, and realized versus bipower variation separates total variation from its continuous part, with their gap flagging jumps.

    Assumptions & limitations

    • The order book is reduced to the top of book (best bid and ask with their sizes); depth beyond the touch is not used in the microprice.
    • The tape of microstructure events is deterministic and synthetic, built from explicit sinusoidal imbalance and impact patterns rather than a stochastic order-flow model, so the per-event series is reproducible but illustrative.
    • Price impact is linear in signed order flow (Kyle), with a single constant lambda; nonlinear or transient impact is not modeled.
    • The Roll estimator returns a positive spread only when the serial covariance of price changes is negative; when that covariance is non-negative it reports zero, as the model intends.
    • Realized and bipower variation are computed on the simulated return series and are sensitive to the sampling frequency, which the signature plot is designed to expose.
    • Bipower variation uses the constant mu_1 = E|N(0,1)| = sqrt(2/pi) in its scaling, the standard Barndorff-Nielsen and Shephard normalization.

    Frequently asked questions

    What is the microprice and why not just use the mid?

    The microprice is the size-weighted average of the best bid and ask, P_mu = (P_a*V_b + P_b*V_a)/(V_b + V_a), which equals the mid plus half the spread times the order imbalance. Because it leans toward the side with less size (the side likely to be hit), it is a better short-horizon predictor of where the price goes next than the simple mid. When the two sizes are equal the imbalance is zero and the microprice collapses back to the mid.

    How does the Roll estimator recover the spread?

    Roll (1984) observed that bid-ask bounce makes consecutive trade-price changes negatively correlated: a buy at the ask followed by a sell at the bid creates a reversal. The effective spread is 2 times the square root of minus that serial covariance, S = 2*sqrt(-Cov(Delta p_t, Delta p_{t-1})). It only yields a positive number when the covariance is negative; a non-negative covariance (as can happen with a trending synthetic tape) returns zero.

    What is the signature plot telling me?

    The signature plot shows realized variance as a function of sampling frequency. Sampling too finely picks up microstructure noise and inflates the estimate; sampling too coarsely throws away data and adds variance to the estimate. The plot visualizes this bias-variance tradeoff from Ait-Sahalia, Mykland and Zhang (2005), which is why practitioners sample at an intermediate frequency or use noise-robust estimators.

    What does Kyle lambda measure?

    Lambda is the slope of the linear price-impact relation Delta p = lambda*q + noise, so it says how many price units a unit of signed order flow moves the market. A higher lambda means a thinner, more impactful market where trading moves prices more; a lower lambda means deeper liquidity. It is the inverse of market depth in Kyle's (1985) model of informed trading.

    What is the difference between realized variance and bipower variation?

    Realized variance sums squared high-frequency returns and captures total variation, including jumps. Bipower variation sums products of adjacent absolute returns, scaled by mu_1^{-2}, and is robust to jumps so it estimates only the continuous (diffusive) part. The gap between them is a jump detector: when realized variance sits well above bipower variation, the path contains jumps.

    Is this using real market data?

    No. The tape is a deterministic synthetic sequence built from explicit microstructure equations, so every curve is exactly reproducible and each statistic can be traced to its formula. The point is to show how the microprice, imbalance, Kyle impact, Roll spread, and volatility estimators are defined and interact, not to analyze a specific instrument's live book.

    Methodology last reviewed 2026-10-06. Results are informational and not financial or engineering advice — see our disclaimer.