Model-Fidelity Review for the Seven Academic Strategies
Audit / Issue Found
Seven strategies in the library are named after specific academic models in the market-making literature. Each one was deeply reviewed against the published formula it claims to implement, looking for places where the code diverges from the paper in a way that would affect trading behaviour. The seven are Cartea-Jaimungal, Glosten-Milgrom, Hawkes, microprice, OFI flash, queue-reactive, and Roll. Three real cleanups were applied. Four came back faithful with only documentation-style polish items.
Before the patch
The Cartea-Jaimungal half-spread had a code comment that mis-described which factor was the textbook convention. The math was right but the comment overstated what the paper actually says, which would mislead a future reader.
The OFI flash z-score had a warmup window problem. When the strategy first switches into book-derived order-flow-imbalance mode, the rolling history of book-OFI is empty, and the standard deviation in the z-score calculation falls back to candle-derived OFI. Book OFI and candle-proxy OFI live on completely different numerical scales. During the first few cycles, the z-score therefore mixes a book-OFI numerator with a candle-OFI standard-deviation, which is meaningless. If contrarian flash mode was explicitly enabled by the operator, this could trigger spurious flash entries during warmup.
The queue-reactive imbalance calculation, while normally safe because the book-present flag gates it, had no explicit guard against the corner case where bid and ask top-volumes are both zero or non-finite despite the flag claiming the book is present. If that ever happened, a not-a-number would be pushed into the rolling imbalance history and corrupt the rolling mean for the rest of the session.
The Roll-model ensemble had an asymmetric fallback. When both Roll and Corwin-Schultz estimators failed, the code used the full configured fallback half-spread. When only one estimator produced a value and the other failed, the code only enforced a floor of one-third of the fallback. A single-estimator number is less robust than the full ensemble, so the floor on that path was too tight.
After the patch
The Cartea-Jaimungal comment was rewritten to describe the skew-scale parameter accurately, without overstating which factor is the textbook value. The math was already correct so the code itself did not need a change.
The OFI flash strategy now refuses to fire a contrarian flash entry when the book-OFI history has fewer than five entries, even if all other conditions are met. The strategy continues passive quoting during this window, which is safe. Once five book-OFI samples have accumulated, the z-score becomes self-consistent and flash entries are allowed again, subject to the existing enable flag.
The queue-reactive imbalance calculation now explicitly checks that the denominator is positive before dividing, and runs an isFinite guard on the result. If either check fails the imbalance defaults to zero for that cycle and the corrupt value never enters the rolling mean.
The Roll-model ensemble now picks the floor based on how many estimators produced a value. When both are alive it keeps the original one-third floor. When only one produced a value, it uses one-half the fallback, which is a more conservative minimum.
The Hawkes-process, Glosten-Milgrom, and microprice strategies came back faithful with no fixes needed. Each has intentional, documented deviations from the textbook (an EMA anchor in Glosten-Milgrom, a heuristic intensity-to-spread mapping in Hawkes, an Avellaneda-Stoikov reservation-price approach in microprice) but the deviations are economically sound and disclosed in the code.
Bottom line
The academic strategies are substantially faithful to the models they claim to implement. Three small but real bugs in the warmup or edge-case handling were fixed. The deeper model implementations check out.