Preparing your design workspace

Loading the problem and your saved attempt…

Design the Order Messages Between a Trading Firm and an Exchange

Define the message types a firm and an exchange send for new orders, cancels and fills, the fields each needs, and how the firm keeps an exact view of every order.

For this exercise, assume a trading firm sends orders to one stock exchange over a single long-lived connection, called a session. The exchange keeps an order book for each stock and does the matching; how it matches is not part of this exercise. The firm can send a limit order to buy or sell a whole number of shares of one stock at a price, and it can ask the exchange to cancel whatever is left of an order. The exchange answers every request and later tells the firm about each fill, and a fill may cover only part of an order. A cancel request can pass a fill on the way, so the firm may hear that its order filled after it asked to cancel. Prices are whole numbers of ticks, where one tick is 0.01, and messages in one direction arrive in the order they were sent. Either side may restart or lose the connection, so both sides must be able to notice a missing or repeated message.

Design the message set: list every kind of message, the side that sends it, and the fields it needs. Then design the objects on the firm's side that build these messages and use the exchange's replies to know every order's state and remaining quantity at all times.

Changing an open order, market data, the exchange's matching rules, clearing and settlement, and the byte-level encoding are out of scope; one follow-up adds order changes.