Let bn,qnb,an,qna be the best bid, its size, the best ask and its size after the n-th book event. The order-flow imbalance contribution of event n is
en=1bn≥bn−1qnb−1bn≤bn−1qn−1b−1an≤an−1qna+1an≥an−1qn−1a,
and the order-flow imbalance (OFI) over an interval is the sum of the en in it (Cont, Kukanov and Stoikov, 2014).