An in-flight order is an order in a pending state: a request about it has been sent and its answer has not arrived, so the order may have changed at the venue in ways the firm does not know yet. A cancel–fill race occurs when a fill and a request to cancel or replace the same order cross: the fill happens at the venue before the request arrives there, and its report reaches the firm after the request was sent.
fig_races.py (deterministic).