A book invariant is a property every correct book satisfies after every event, checked by the builder in its debug builds: each level’s quantity equals the sum of its orders’ quantities, no empty level is reported, and the best bid is below the best ask.
bench_books.py.