What you will learn
- No-lookahead cases
- Cancel-fill races
- Missing data behavior
- Compare simulation against recorded executions
No-lookahead cases
Use no-lookahead cases in which a future price would tempt an incorrect early action. The expected result should come from an independently specified event trace, not from the same simulator logic.
Cancel-fill races
Test cancel-fill races and duplicate events. A repeated execution message should not double exposure, and a cancel acknowledgement should not erase an earlier valid fill. Stable identities and transition rules are essential.
Missing data behavior
Missing data should invoke a documented policy. A simulator must not silently fill an order through an interval with no supporting observations while claiming exact realism. Mark affected outcomes and assess sensitivity.
Compare simulation against recorded executions
Compare simulated behavior with recorded executions only after matching instrument, inputs and timing. Differences reveal model limitations but may also reflect incomplete observation of the live environment. Report the limits rather than forcing exact agreement by hindsight tuning.
Worked example
A fill event is replayed twice after a restart. The correct accounting should recognize its stable identity and leave exposure unchanged on the second delivery.
Try it yourself
Design a regression test for this duplicate and a separate test for a fill arriving before a cancel acknowledgement.
Show the worked solution
Replay the duplicate and assert unchanged position, cash and fill count. For the race, retain the valid fill and cancel only remaining quantity. Expected states must be specified independently of the implementation.
Apply this to your course project
Implement or specify a simulator and demonstrate its behavior on adversarial price paths.
Keep the calculation inputs, assumptions and decisions with your work. Practical exercises are self-reviewed; the scored knowledge checks assess the questions shown, not an independent certification of practical competence.