Realism and the stylized facts¶
Prices, returns and order flow in real markets share a set of statistical
signatures, the stylized facts (Cont 2001; Bouchaud, Bonart, Donier and Gould
2018). They hold across assets, venues and decades, so a market model that misses
them is missing something about how markets work. microbook measures them with
microbook.stylized, and
MarketConfig.realistic() is calibrated
to reproduce them.
The facts¶
| Fact | What it says | Statistic |
|---|---|---|
| Fat tails | large returns are far more common than under a normal law | excess kurtosis; Hill tail index ≈ 3 |
| Aggregational Gaussianity | returns look more normal over longer horizons | kurtosis falls as the horizon grows |
| No linear autocorrelation | past returns do not predict future returns | ACF of returns ≈ 0 |
| Volatility clustering | large moves follow large moves | ACF of |returns| > 0, decaying slowly |
| Long memory of order signs | buys follow buys for a long time | ACF of trade signs ∝ lag^−γ, γ ≈ 0.5 |
| Square-root impact | a metaorder of size Q moves the price by about σ√(Q/V) | impact ∝ Q^δ, δ ≈ 0.5 |
Measuring them¶
Every function in microbook.stylized works on plain sequences: a mid path of
(time, mid) pairs and a list of fills. The same code therefore measures a
simulation and a replayed historical day.
stylized_facts() computes the whole set at
once:
from microbook.sim import MarketConfig, build_market
from microbook.stylized import stylized_facts
horizon = 50_000
market = build_market(MarketConfig.realistic(seed=3, snapshot_every=1_000), horizon=horizon)
sim = market.run(horizon)
facts = stylized_facts(sim.result.mid_path, sim.result.fills, end=horizon)
print(f"Hill tail index {facts.hill_alpha:.2f}")
# Hill tail index 2.67
print(f"kurtosis {facts.kurtosis_short:.1f} at 10 steps, {facts.kurtosis_long:.1f} at 1,000")
# kurtosis 41.9 at 10 steps, 0.3 at 1,000
print({lag: round(v, 2) for lag, v in facts.abs_return_acf.items()})
# {1: 0.31, 10: 0.11, 100: 0.05}
print({lag: round(v, 2) for lag, v in facts.sign_acf.items()})
# {1: 0.36, 10: 0.26, 100: 0.04, 1000: 0.01}
A single seed is noisy (the fitted sign exponent facts.sign_gamma varies a lot
from run to run), so the published numbers below average several.
The building blocks are public too:
sample_returns(),
acf(),
excess_kurtosis(),
hill_tail_index(),
aggressor_signs(),
power_law_fit() and, for impact,
metaorder_impacts() and
impact_curve().
Results¶
examples/stylized_facts.py measures both presets over 8 seeds of 200,000 steps,
with a step read as one second (about 20 s on a laptop):
| Statistic | MarketConfig() |
.realistic() |
Real markets |
|---|---|---|---|
| Tail index (Hill, 10-step returns) | 7.1 | 2.7 | ≈ 3 (2–5) |
| Excess kurtosis at 10 / 100 / 1,000 steps | 4.5 / 0.2 / −0.6 | 40 / 4.0 / 1.6 | large, falling with horizon |
| Return autocorrelation, lag 1 (100-step returns) | 0.52 | −0.01 | ≈ 0 |
| Return autocorrelation, lag 1 (10-step returns) | 0.04 | −0.08 | ≈ 0 or slightly < 0 (bid-ask bounce) |
| |Return| autocorrelation at 10 / 100 / 1,000 steps | 0.11 / 0.02 / 0.00 | 0.32 / 0.10 / 0.03 | > 0, slow decay |
| Order-sign autocorrelation, lag 1 / 10 / 100 / 1,000 | 0.39 / 0.36 / 0.14 / −0.01 | 0.39 / 0.31 / 0.05 / 0.02 | ≈ c·lag^−0.5 |
| Order-sign decay, fitted exponent | – | 0.52 | ≈ 0.5 |
| Impact prefactor Y in I = Yσ√(Q/V) | – | 0.49 ± 0.02 | 0.5–1 |

The realistic preset reproduces every fact in the table, and held-out seeds (11–18) give the same numbers within their error bars.
Against real data¶
The literature values above come from many markets and studies.
examples/real_data_facts.py measures one real market directly, with the same
code: every public BTC/USD trade on Kraken on 4 June 2024 (UTC), 26,649 trades
from 15,976 aggressive orders, downloaded from Kraken's public API and cached
after the first run. The date is fixed, so anyone gets the same data.
python examples/real_data_facts.py # about a minute
python examples/real_data_facts.py --start 2024-06-05T00:00:00 --hours 24
| Statistic | Simulator (.realistic()) |
Kraken BTC/USD, 2024-06-04 |
|---|---|---|
| Tail index (Hill, 10 s returns) | 2.74 | 3.04 |
| Excess kurtosis at 10 s / 100 s / 1,000 s | 40.1 / 4.0 / 1.6 | 28.0 / 6.7 / 0.9 |
| Return autocorrelation, lag 1 (100 s returns) | −0.01 | 0.05 |
| Return autocorrelation, lag 1 (10 s returns) | −0.08 | 0.11 |
| |Return| autocorrelation at 10 s / 100 s / 1,000 s | 0.32 / 0.10 / 0.03 | 0.14 / 0.10 / 0.08 |
| Order-sign autocorrelation, lag 1 / 10 / 100 / 1,000 | 0.39 / 0.31 / 0.05 / 0.02 | 0.28 / 0.17 / 0.03 / 0.02 |
| Order-sign decay, fitted exponent | 0.53 | 0.46 |
The simulator column averages 8 seeds of 200,000 steps, a step read as one second; the Kraken column is one day. They agree on every fact: fat tails that thin out with the horizon, little linear autocorrelation, volatility clustering, and order signs with long memory decaying at about lag^−0.5. The magnitudes differ, and some differences are in the data rather than the model:
- Crypto, not equities. The preset is calibrated to equity-like statistics. Bitcoin trades around the clock, with no open or close, and one exchange sees only part of the market's flow.
- Trade prices, not mids. The public data has trades but no quotes, so the real price path is the last trade price. On a day with one aggressive order every five seconds, many 10-second intervals have no trade and the price is stale; stale prices give the positive lag-1 autocorrelation of 10-second returns (0.11). The simulator's mid moves with every quote and shows the usual small negative value from bid-ask bounce.
- Clock time vs trade time. Both columns sample on a clock in seconds, but the simulator's activity is the same at every hour, while real activity follows the time of day: it is busiest when the US and European markets are open. That daily pattern alone keeps the autocorrelation of |returns| positive at long lags, which is part of why it is higher in the real data at 1,000 s (0.08 against 0.03).
- One day is one sample. The Kraken numbers carry the noise of a single
day; the fitted exponent and the long-lag autocorrelations move from day to
day. Run another day with
--start.
Price impact is not compared: it needs metaorders, and public trade data does not say which trades belong to one.
Where each fact comes from¶
- Fat tails and volatility clustering come from the stochastic volatility of the fundamental and from self-exciting market orders. The simple market has neither, so its returns are close to normal beyond short horizons.
- No autocorrelation. In the simple market, fixed-size informed trades close a gap slowly, so prices trend for a while after the fundamental moves (lag-1 autocorrelation 0.52 at 100 steps). Arbitrage capital that grows with the gap closes it quickly and removes the momentum.
- Long memory of order signs comes from metaorder splitting. With Pareto metaorder sizes of exponent α between 1 and 2, the sign autocorrelation decays as lag^−(α−1). The preset uses α = 1.4; small children (2 shares, one per step) make one metaorder span hundreds of trades.
- Square-root impact comes from the same splitting: a metaorder moves the price faster than arbitrage pulls it back, and the race gives a concave impact curve (fitted exponent 0.51).
What the model does not capture¶
- Impact depends too much on speed. Here a metaorder's impact is a race between its execution and the arbitrageurs, so Y is roughly proportional to execution speed. With one child order every 10 / 4 / 2 / 1 steps, Y is 0.0 / 0.14 / 0.27 / 0.49, everything else fixed. In real markets the participation rate matters much less. The preset matches the square-root law at its calibrated speed, but the law does not emerge at every speed.
- The tail index (2.7) is slightly below the typical 3.
- The calibration targets equity-like statistics in "seconds". It is not fitted to any particular market's data.