Validate an Order Lifecycle Event Stream for Protocol Violations

Last updated: November 29, 2026

Quick Overview

Given a chronological list of order events (NEW, ACK, FILL, CANCEL) keyed by order id, return every event that violates the order lifecycle, such as fills before acknowledgement, overfills, or events after a terminal state.

Virtu Financial
Coding & Algorithms
Software Engineer
Virtu Financial
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given a chronological list of order events (NEW, ACK, FILL, CANCEL) keyed by order id, return every event that violates the order lifecycle, such as fills before acknowledgement, overfills, or events after a terminal state.

Virtu routes and receives very large volumes of orders over FIX for both market making and its agency execution business, and a drop-copy or post-trade checker must flag broken lifecycles before they reach risk and regulatory reporting. This assessment checks clean state-machine modeling and careful handling of each transition.

What the Interviewer Expects
  • Model each order as a small state machine (PENDING, OPEN, FILLED, CANCELED)
  • Track cumulative filled quantity against order quantity
  • Report violations with the event index and a reason instead of stopping at the first one
  • Handle unknown ids and duplicate NEW messages
  • Keep the solution single pass and O(n)
Key Topics to Cover
state machine
hash map
FIX order lifecycle
validation
single pass
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you treat a late fill that arrives after a cancel was acknowledged?
  • How would you extend this to cancel-replace (amend) messages?
  • What if events from different sessions arrive interleaved and slightly out of order?
  • How would you make this run continuously on a live drop copy?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: list of events with type, order_id, and qty for NEW and FILL. Output: list of (index, reason). Rules: NEW must be unique and have positive quantity; ACK only once, only on a pending ord...

High-Level Design

One dictionary from order id to {qty, filled, status}. Process events in order and dispatch on type. A violating event does not mutate state, which mirrors how a downstream system would reject it....


Submit Your Answer
Markdown supported

Related Questions