---
title: "Matching Algorithms and Implied Spreads"
book: "Markets I: The Ecosystem and Exchange-Traded Markets"
subject: quant
language: en
chapter: 19
exercises: 8
source: https://one-course.com/books/quant/1/en/chapter/19-matching-algorithms-and-implied-spreads
---

# Chapter 19 — Matching Algorithms and Implied Spreads

Two traders bid the same price for the same future. A sell order arrives, smaller than their combined size. In the equity-index future the trader who bid first is filled completely before the other receives a single lot. In the short-term interest-rate future next to it, on the same exchange, the two share the sale in proportion to the sizes they showed, and the one who arrived first has no advantage at all. The first rule pays for speed; the second pays for size, and invites everyone to show more than they want. The allocation rule is a few lines in the exchange’s documentation and it decides what kind of firm can make markets in the product. A second mechanism, invisible on a screen, links the books of different expiries: the best bid in a [calendar spread](#def-m1-matching-algorithms-and-implied-spreads-calendar) is often an order nobody entered.

## 19.1 Price-time priority

**Definition 19.1 (Price-time priority).**

Under *price-time priority* (first in, first out, FIFO) an incoming order trades against resting orders at the best price in the order of their priority timestamps, oldest first, each filled completely before the next receives anything.

An order’s timestamp is set when it enters the book. On most exchanges it is renewed, and the place in the queue lost, when the order’s price is changed or its quantity increased; reducing the quantity keeps the place. Under FIFO a resting order has two attributes that matter: its price and its position in the queue. At a large tick ([Figure 18.2](https://one-course.com/books/quant/1/en/chapter/18-futures-contracts-and-their-exchanges#fig-m1-futures-contracts-and-exchanges-tickbp)) the price rarely changes, queues are long, and position is the whole game: being near the front means being filled by small, uninformed orders; being at the back means being filled only when a large order sweeps the level, which is when the price is about to move against the fill. The economics of the queue are developed in One Quant Book 10.

## 19.2 Pro rata and its variants

**Definition 19.2 (Pro-rata allocation).**

Under *pro-rata allocation* an incoming order is shared among all resting orders at the best price in proportion to their sizes. Allocations are rounded down to whole lots, allocations below a product-specific minimum may be dropped, and what rounding leaves over is distributed by a secondary rule, often time priority.

**Definition 19.3 (Top-order allocation and lead market maker).**

A *top-order allocation* gives the order that first improved the market, establishing a new best price, a priority allocation before any other rule applies. A *lead market maker* is a firm which, in exchange for quoting obligations, receives a set percentage of each incoming order at the best price before the rest is allocated.

Real algorithms are sequences of such steps. One family in use: the top order first, up to a percentage of the aggressor; then [lead market makers](#def-m1-matching-algorithms-and-implied-spreads-top); then a percentage of what remains by time; then the rest pro rata with a minimum allocation; then leftovers by time.

**As of September 2026 — Which products use which rule.**

**CME Group** documents nine algorithms, among them FIFO, FIFO with [lead market maker](#def-m1-matching-algorithms-and-implied-spreads-top), Pro Rata, Allocation (top order, then pro rata with a minimum of two lots, then FIFO), Threshold Pro Rata (with and without a [lead market maker](#def-m1-matching-algorithms-and-implied-spreads-top)) and Configurable, a split of FIFO and pro rata with set percentages. A data vendor’s survey of the exchange’s definitions assigns FIFO to the equity-index, Treasury-note and crude-oil outrights, about 70% of volume; Configurable to two-year notes, federal funds and the grains, about 13%; Allocation to three-month SOFR outrights, about 10%; and Threshold Pro Rata with a [lead market maker](#def-m1-matching-algorithms-and-implied-spreads-top) to options on the ten-year note. **Eurex** supports time, pro-rata and time-pro-rata allocation, the last giving older orders more than their proportional share; on 30 March 2026 it moved its money-market futures, the three-month Euribor among them, from time to time-pro-rata allocation.

The pattern is economic. Products whose price moves many ticks a day keep FIFO: the tick is small, improving the price is the way to get priority, and queues are short. Short-term interest-rate futures move a tick or two a day: under FIFO the queue at each price would be days long and nobody but the first arrival would bother to quote. Sharing fills pro rata keeps many firms quoting size at a price that does not move.

![One hundred lots arrive at a level holding four orders, listed in time priority with their sizes. The same aggressor, the same book, three rules, three different sets of winners. Data: the chapter’s build.](https://one-course.com/images/onecourse/chapters/quant-1/m1-matching-algorithms-and-implied-spreads/fig-b971d7a9d47d.svg)

***Figure 19.1.** One hundred lots arrive at a level holding four orders, listed in time priority with their sizes. The same aggressor, the same book, three rules, three different sets of winners. Data: the chapter’s build.*

**Proposition 19.4 (Pro rata rewards shown size).**

Under pro rata without minimum, an order of size $s$ in a level whose other orders total $Q$ receives $\lfloor as/(Q+s)\rfloor$ of an aggressor of size $a
\le Q+s$, increasing in $s$ and independent of arrival time. A trader who wants $w$ lots from a typical aggressor $a$ must show about $s = wQ/(a-w)$, and is exposed to receiving up to $s$ when a larger aggressor arrives.

**Example 19.5 (Eighty-seven to get eight).**

A level holds 1 000 lots and typical aggressors are 100 lots. To receive 8 the trader shows $8 \times 1\,000/92 = 87$ lots (86 would receive 7). If a 1 000-lot order arrives instead, the trader receives 80: ten times the intention, at the moment the price is most likely to move through the level. Displayed size in a pro-rata book therefore overstates the quantity anyone wishes to trade, and much of it disappears when a large order appears.

![Pro rata with a minimum allocation of two lots: what a newcomer at the back of a 1 000-lot level receives from a 100-lot aggressor, against the size it shows. Below 21 lots it receives nothing. Data: .](https://one-course.com/images/onecourse/chapters/quant-1/m1-matching-algorithms-and-implied-spreads/fig-5fc14410fd5a.svg)

***Figure 19.2.** Pro rata with a minimum allocation of two lots: what a newcomer at the back of a 1 000-lot level receives from a 100-lot aggressor, against the size it shows. Below 21 lots it receives nothing. Data: [Proposition 19.4](#prop-m1-matching-algorithms-and-implied-spreads-oversize).*

![Expected fill of a 10-lot order in a 500-lot level when one aggressor of random size (exponential, mean 120) arrives. Under FIFO the front of the queue is worth four times the pro-rata share and the back almost nothing; the curves cross with 170 lots ahead. Data: the tutorial’s simulation.](https://one-course.com/images/onecourse/chapters/quant-1/m1-matching-algorithms-and-implied-spreads/fig-8587f7996b28.svg)

***Figure 19.3.** Expected fill of a 10-lot order in a 500-lot level when one aggressor of random size (exponential, mean 120) arrives. Under FIFO the front of the queue is worth four times the pro-rata share and the back almost nothing; the curves cross with 170 lots ahead. Data: the tutorial’s simulation.*

## 19.3 Calendar spreads and implied prices

**Definition 19.6 (Calendar spread).**

A *calendar spread* is an exchange-listed instrument whose purchase is the simultaneous purchase of one expiry and sale of another of the same product, at a quoted price difference. It has its own order book, its own tick, and trades as one order with no risk of being filled on one leg only.

The convention used here: the spread is front minus back, so buying the spread buys the front month and sells the back. Rolling a long position forward is selling the spread.

**Definition 19.7 (Implied-in and implied-out).**

An *implied-in* order is a spread order which the matching engine derives from orders resting in the outright books: a bid in the front month and an offer in the back month imply a bid in the spread at the difference of their prices, for the smaller of their sizes. An *implied-out* order is an outright order derived from a spread order and an outright order in the other leg. Implied orders are real: they can be hit, and the engine then executes all the legs at once. Implied orders do not trade against implied orders.

**Proposition 19.8 (Implied prices).**

With $b_F, a_F$ and $b_B, a_B$ the best bids and offers in the front and back months and $b_S, a_S$ those entered directly in the spread:

$$
\begin{align*}
\text{implied-in:}\quad & b_S^{\text{imp}} = b_F - a_B, & a_S^{\text{imp}} &= a_F - b_B,\\
\text{implied-out, front:}\quad & b_F^{\text{imp}} = b_S + b_B, & a_F^{\text{imp}} &= a_S + a_B,\\
\text{implied-out, back:}\quad & b_B^{\text{imp}} = b_F - a_S, & a_B^{\text{imp}} &= a_F - b_S.
\end{align*}
$$

The size of each implied order is the smaller of its components’ sizes.

**Proof.** A seller of the spread sells the front and buys the back. The engine can fill that seller with the front-month bidder and the back-month seller, who together pay $b_F$ and charge $a_B$. The other five are the same argument applied to each leg. ∎

![Implied-in orders. The spread’s implied bid is the front bid minus the back ask, 10\,050 - 10\,023 = 27, for (30, 10) = 10 lots; its implied ask is 10\,052 - 10\,020 = 32 for 25. The book a trader sees is the better of direct and implied on each side, sizes adding at equal prices.](https://one-course.com/images/onecourse/chapters/quant-1/m1-matching-algorithms-and-implied-spreads/fig-38e59b9c3565.svg)

***Figure 19.4.** [Implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied) orders. The spread’s implied bid is the front bid minus the back ask, $10\,050 - 10\,023 = 27$, for $\min(30, 10) = 10$ lots; its implied ask is $10\,052 - 10\,020 = 32$ for 25. The book a trader sees is the better of direct and implied on each side, sizes adding at equal prices.*

Implied matching joins the liquidity of all expiries: a hedger rolling a position meets, through the spread, everyone quoting either month. It also means that an order entered in one book can trade because of an event in another, that an order’s effective queue position depends on the engine’s rule for ranking implied against direct orders at the same price, and that a simulator which ignores implieds understates the liquidity of the spread and misstates fills in the outrights.

## 19.4 What the feed shows

**Definition 19.9 (Market by price and market by order).**

A *market-by-price* feed publishes, for each price level, the total quantity and the number of orders. A *market-by-order* feed publishes every order individually, with an identifier and its priority, and every change to it.

With market by order a firm knows its own position in a FIFO queue exactly and sees who is ahead in size; with market by price it must estimate its position from the sequence of updates, guessing whether each decrease in quantity was a cancellation (ahead or behind?) or a trade. Implied quantities are usually published separately from the direct book, or not at all beyond the best level. Reading these feeds is the subject of [Chapter 28](https://one-course.com/books/quant/1/en/chapter/28-reading-market-data#ch-m1-reading-market-data); what matters here is that the allocation rule determines which feed is worth paying for.

## 19.5 Tutorial: three allocation rules

**Goal.** Implement FIFO, pro rata with a minimum, and a configurable split; compare their fills; compute implied spread prices. **End state:** the three data figures of this chapter.

1. **FIFO**, and a helper that never over-fills an order. `def _take (fills: dict [str , int ], order: Resting, want: int , left: int ) -> int : got = min (want, order.qty - fills.get(order.oid, 0 ), left) if got > 0 : fills[order.oid] = fills.get(order.oid, 0 ) + got return left - max (got, 0 ) def fifo (book: list [Resting], qty: int ) -> dict [str , int ]: fills: dict [str , int ] = {} left = qty for o in book: left = _take(fills, o, o.qty, left) return fills` **Listing 19.1.** Time priority: walk the queue. code/firm/match/firm_match.py
2. **Pro rata.** Integer arithmetic only: floors, a minimum, and leftovers by time. `def _pro_rata_into (fills: dict [str , int ], book: list [Resting], qty: int , min_alloc: int ) -> dict [str , int ]: open_qty = {o.oid: o.qty - fills.get(o.oid, 0 ) for o in book} total = sum (open_qty.values()) left = min (qty, total) if left <= 0 : return fills target = left for o in book: share = target * open_qty[o.oid] // total if share >= min_alloc: left = _take(fills, o, share, left) for o in book: # residual from rounding: time priority left = _take(fills, o, o.qty, left) return fills` **Listing 19.2.** Pro-rata allocation on the open quantities. code/firm/match/firm_match.py
3. **[Implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied).** `def implied_in (front: Quote, back: Quote) -> Quote: """Spread (front minus back) implied by the two outright books.""" bid = front.bid - back.ask if front.bid is not None and back.ask is not None else None ask = front.ask - back.bid if front.ask is not None and back.bid is not None else None return Quote(bid, min (front.bid_qty, back.ask_qty) if bid is not None else 0 , ask, min (front.ask_qty, back.bid_qty) if ask is not None else 0 )` **Listing 19.3.** The spread quote implied by two outright quotes. code/firm/match/firm_match.py
4. **Property tests.** On three hundred random books every algorithm must allocate exactly $\min(\text{aggressor}, \text{resting})$ lots and never more than an order’s size.

**What to change next.** Implement time-pro-rata: weight each order by size times a decreasing function of its rank in time, and find the weights for which the first order of [Figure 19.1](#fig-m1-matching-algorithms-and-implied-spreads-alloc) receives the same as under the split rule.

## 19.6 Build: allocation and implieds

**Purpose.** The matching engine of the miniature firm’s simulated exchange (One Quant Book 10) delegates one decision to this module: given a level and an aggressor, who gets what. The backtester uses the same code, so that simulated fills obey the rule of the product simulated.

**Interface.** `Resting(oid, qty, lmm, top)` in time priority; `fifo(book, qty)`, `pro_rata(book, qty, min_alloc)`, `configurable(book, qty, top_pct, lmm_pct, fifo_pct, min_alloc)`, each returning fills by order; `Quote`; `implied_in(front, back)`, `implied_out_front(spread, back)`, `best_of(direct, implied)`.

**Rules.** Integers only. Conservation: fills sum to $\min(\text{qty},
\text{resting})$. No order is over-filled. Implied quantity never matches implied quantity: `best_of` combines a direct and an implied quote and is never applied to two implied ones.

**Acceptance tests.** `code/firm/match/tests/`: the chapter’s worked allocations; the split rule; conservation on random books; implied prices with an empty side.

**Stretch.** A butterfly (three expiries) and the second generation of implieds it creates; decide, as an exchange must, where to stop.

Sources and further reading

- CME Group Client Systems Wiki, *Supported Matching Algorithms* , *CME Globex Matching Algorithms* and *Implied Orders* .
- Databento, “CME matching algorithms explained” (survey of algorithms by product and share of volume).
- Eurex, *Matching principles* , and the circular on money-market derivatives (allocation scheme from 30 March 2026).

## 19.7 Exercises

**Exercise 19.1 ★.**

The level of [Figure 19.1](#fig-m1-matching-algorithms-and-implied-spreads-alloc) (A 10, B 200, C 40, D 250, in time order) receives an aggressor of 230 lots under FIFO. Give the fills.

**Solution of Exercise 19.1.**

A 10, B 200, C 20 of its 40, D nothing.

**Exercise 19.2 ★.**

Same level, aggressor of 60 lots, pro rata without minimum and leftovers by time. Give the exact shares, the floors, the leftover and the fills.

**Solution of Exercise 19.2.**

Shares $60 \times (10, 200, 40, 250)/500 = 1.2$, 24, 4.8, 30. Floors 1, 24, 4, 30: 59 lots. The one lot left over goes to the oldest order, A. Fills: A 2, B 24, C 4, D 30.

**Exercise 19.3 ★.**

Front month 10 050 bid for 30, offered at 10 052 for 25; back month 10 020 bid for 40, offered at 10 023 for 10. Give the [implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied) bid and offer of the spread with their sizes.

**Solution of Exercise 19.3.**

Bid $10\,050 - 10\,023 = 27$ for $\min(30, 10) = 10$. Offer $10\,052 - 10\,020 =
32$ for $\min(25, 40) = 25$.

**Exercise 19.4 ★★.**

Under FIFO, which of these actions on a resting order lose its place in the queue on most exchanges: reducing its size; increasing its size; changing its price; cancelling and re-entering it? How would you design an order manager that needs to *increase* its size at a level without giving up the priority it has?

**Solution of Exercise 19.4.**

Reducing the size keeps the place. Increasing it, changing the price, and cancelling and re-entering all lose it (the last by construction). To add size without losing priority, never amend upwards: leave the old order where it is and enter a *second* order for the additional quantity, which joins the back of the queue. The order manager must therefore handle several live orders per price level and cancel the youngest first when reducing.

**Exercise 19.5 ★★.**

Verify [Example 19.5](#ex-m1-matching-algorithms-and-implied-spreads-87). Then suppose every participant reasons the same way and multiplies its size by ten. What happens to each one’s fills, to the displayed depth, and to the information in the displayed depth?

**Solution of Exercise 19.5.**

$8 \times 1\,000/92 = 86.96$, so 87; $\lfloor 100 \times 87/1\,087\rfloor = 8$, $\lfloor 100 \times 86/1\,086\rfloor = 7$, $\lfloor 1\,000 \times 87/1\,087\rfloor
= 80$. If everyone multiplies by ten, shares are unchanged: each receives what it received before, the displayed depth is ten times larger, and each is exposed to ten times more on a sweep. Displayed depth then measures the participants’ tolerance for being over-filled, not their wish to trade, which is why depth in pro-rata products evaporates in fast markets.

**Exercise 19.6 ★★.**

A [market-by-price](#def-m1-matching-algorithms-and-implied-spreads-mbo) feed shows the best bid going from 480 lots in 12 orders to 465 lots in 11 orders, with no trade message. Your own 10-lot order is somewhere in that level under FIFO. What happened, and what can and cannot be said about your queue position? What would market by order add?

**Solution of Exercise 19.6.**

One order of 15 lots was cancelled (a trade would have produced a trade message). If it was ahead of yours, 15 fewer lots are ahead; if behind, nothing changed. Market by price does not say which. A common estimate assumes cancellations are spread in proportion to the quantity ahead and behind, or, more conservatively, that they all come from behind. Market by order gives the cancelled order’s identifier and hence its place: the position is known exactly.

**Exercise 19.7 ★★★.**

*Coding.* From `position.csv`: report the expected fill at the front of the queue under FIFO, the pro-rata expected fill, their ratio, and the number of lots ahead beyond which pro rata would have been better.

**Solution of Exercise 19.7.**

Front of a FIFO queue: 9.56 of the 10 lots. Pro rata: 2.34 wherever the order stands. Ratio 4.1. Pro rata is better for an order with 170 lots or more ahead of it in a 500-lot level.

**Exercise 19.8 ★★★.**

*Find the flaw.* “The product is pro rata with a two-lot minimum. I will quote 5 lots on each side at the best price, in levels of about 2 000 lots, and collect my fair share of the flow, about 0.25% of each trade.” Typical aggressors are 100 lots. What will this trader collect, and why?

**Solution of Exercise 19.8.**

The exact share of a 100-lot aggressor is $100 \times 5/2\,005 = 0.249$ lot: it rounds down to zero, and with a two-lot minimum nothing smaller than 41 lots shown ($\lfloor 100 \times 41/2\,041\rfloor = 2$) is allocated anything pro rata. Leftovers go by time to older orders. The trader collects nothing from ordinary flow and is filled only when an order of 800 lots or more sweeps the level: a portfolio of exclusively bad fills. In a pro-rata product there is a minimum viable size, and it is large.

## 19.8 Problem: The Implied Book

**Problem 19.1.**

Weekend problem — two expiries, one spread, one engine

Prices are in ticks. Front month (Z): bid 10 050 $\times$ 30, ask 10 052 $\times$ 25. Back month (H): bid 10 020 $\times$ 40, ask 10 023 $\times$ 10. Orders entered directly in the Z–H spread: bid 28 $\times$ 5, ask 32 $\times$ 7. The spread is front minus back.

**Part I — [Implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied).**

1. Give the [implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied) bid of the spread, with its size.
2. Give the [implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied) ask, with its size.
3. Give the spread book a trader sees at the best level.
4. Why can the implied bid (27) not be above the direct ask (32) for long? What would happen if it were?
5. Explain why implied orders must not match implied orders.

**Part II — A roll.** A fund sells 12 spreads at market (it rolls a long position forward).

6. Which orders does it trade against, at which prices?
7. Give its average price.
8. Which trades print in the outright books, and at which prices?
9. Give the three best-level books after the trade.
10. The fund could have sold 12 Z and bought 12 H itself. Give the prices it would have obtained from the displayed outright books, and the difference.

**Part III — [Implied-out](#def-m1-matching-algorithms-and-implied-spreads-implied) and a new order.** Return to the initial books.

11. Give the [implied-out](#def-m1-matching-algorithms-and-implied-spreads-implied) bid and ask in the front month, from the direct spread orders and the back month.
12. Do they improve the front month’s displayed market?
13. A new offer of 20 lots at 10 021 enters the back month. Give the new [implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied) bid of the spread.
14. Does the new order trade? What would it take?
15. A [market maker](https://one-course.com/books/quant/1/en/chapter/1-what-a-trading-firm-does#def-m1-what-a-trading-firm-does-market-maker) rests a bid of 50 at 28 in the spread. After the order of question 13, where does he stand relative to the implied bid, and what does that tell him?

**Part IV — Judgement.**

16. Your backtest of a front-month strategy ignores the spread book. Name two ways its fills are wrong.
17. The outrights are FIFO. An [implied-out](#def-m1-matching-algorithms-and-implied-spreads-implied) order and a direct order rest at the same price. Why does the engine’s ranking rule between them matter to a [market maker](https://one-course.com/books/quant/1/en/chapter/1-what-a-trading-firm-does#def-m1-what-a-trading-firm-does-market-maker) ?
18. Why do exchanges publish implied quantity only at the best level or two?
19. State the *named result* : the implied best bid of the spread and the displayed best bid, with sizes.
20. In one sentence: what does implied matching do for a hedger?

**Solution of Problem 19.1.**

**1.** $10\,050 - 10\,023 = 27$ for 10. **2.** $10\,052 - 10\,020 = 32$ for 25. **3.** Bid 28 for 5 (direct); ask 32 for 32 (7 direct and 25 implied). **4.** It would mean the front bid exceeds the back ask plus a price at which someone is willing to sell the spread: the engine would match the three orders at once. Crossed implieds against direct orders trade immediately; they are never displayed. **5.** An implied bid and an implied ask that crossed would consist entirely of outright orders that do not cross in their own books; matching them would require chains of legs in further instruments, without limit. Exchanges cut the recursion: every match contains at least one direct order. **6.** The direct bid, 5 at 28; then the implied bid, 7 at 27. **7.** $(5 \times 28 + 7 \times 27)/12 = 27.42$. **8.** For the implied part: 7 Z bought by the front-month bidder at 10 050 and 7 H sold by the back-month seller at 10 023. The direct part prints in the spread only (the legs are assigned prices by an exchange convention and do not touch the outright books). **9.** Front: bid 10 050 $\times$ 23, ask unchanged. Back: bid unchanged, ask 10 023 $\times$ 3. Spread: bid 27 $\times$ 3 (implied), ask 32 $\times$ 32. **10.** Sell 12 Z at 10 050; buy 10 H at 10 023 and 2 at the next offer, 10 024 at best: a spread of at most 26.83, against 27.42, with the risk of the market moving between the two legs. **11.** Bid $28 + 10\,020 = 10\,048$ for 5; ask $32 + 10\,023 = 10\,055$ for 7. **12.** No: the front month shows 10 050 at 10 052, better on both sides. **13.** $10\,050 - 10\,021 = 29$ for $\min(30, 20) = 20$. **14.** No. In its own book the best bid is 10 020, and the [implied-out](#def-m1-matching-algorithms-and-implied-spreads-implied) back bid, $b_F - a_S = 10\,050 - 32 = 10\,018$, is lower still. It would trade if someone sold the spread at 29 or better, or bid 10 021 in the back month. **15.** One tick behind: the displayed best bid is now 29 for 20, implied. To be at the front again the [market maker](https://one-course.com/books/quant/1/en/chapter/1-what-a-trading-firm-does#def-m1-what-a-trading-firm-does-market-maker) must bid 29, and where that order ranks against the implied 20 lots depends on the engine’s rule. An order in the back month has just repriced the spread without any spread order being entered: quotes in one book must be driven by all three. **16.** It misses fills that come from spread sellers through [implied-out](#def-m1-matching-algorithms-and-implied-spreads-implied) orders, and it misjudges queue position: [implied-out](#def-m1-matching-algorithms-and-implied-spreads-implied) quantity can stand ahead of, or behind, the strategy’s order at the same price. It also misses that visible front-month depth includes quantity which vanishes when the *back* month moves. **17.** If implieds rank behind all direct orders, a direct order’s queue position is safe; if they rank by the time they were created, implied quantity can step ahead whenever another book moves. The expected fill, and its [adverse selection](https://one-course.com/books/quant/1/en/chapter/1-what-a-trading-firm-does#def-m1-what-a-trading-firm-does-adverse-selection), differ between the two. **18.** Computing and disseminating implied depth at every level of every combination is expensive and changes with every update in any leg; the best level is what matters for matching. **19.** **Implied best bid 27 for 10; displayed best bid 28 for 5.** **20.** It lets a roll entered as one order draw on the liquidity of both expiries at once, without the risk of being filled on one leg only.

## 19.9 Interview questions

**Interview question 19.1 ★ trader, developer, researcher.**

Explain FIFO and pro-rata matching. Which products use which, and why?

**Solution of Interview question 19.1.**

FIFO fills resting orders at the best price oldest first; pro rata shares the incoming order in proportion to size. Actively moving products with small ticks relative to volatility (equity-index, crude, note futures) are FIFO: priority is earned by improving the price or by arriving first. Products that barely move relative to their tick, short-term interest-rate futures above all, use pro rata or hybrids with top-order and market-maker allocations, so that many firms keep quoting at a price that stays put for hours.

*What the interviewer is looking for: the link between tick size relative to volatility and the rule.*

**Interview question 19.2 ★ developer, trader.**

What is an implied order?

**Solution of Interview question 19.2.**

An order the matching engine derives from orders in related books: two outright orders in different expiries imply a calendar-spread order ([implied-in](#def-m1-matching-algorithms-and-implied-spreads-implied)); a spread order and an outright imply an order in the other leg ([implied-out](#def-m1-matching-algorithms-and-implied-spreads-implied)). It is tradable, all legs execute atomically, and implied never matches implied.

*What the interviewer is looking for: both directions, atomic execution, no implied against implied.*

**Interview question 19.3 ★★ trader, researcher.**

How does a [market maker](https://one-course.com/books/quant/1/en/chapter/1-what-a-trading-firm-does#def-m1-what-a-trading-firm-does-market-maker)’s behaviour differ between a FIFO and a pro-rata product?

**Solution of Interview question 19.3.**

FIFO: invest in latency to reach new price levels first, keep orders alive to preserve queue position, value each position in the queue, show true size. Pro rata: speed matters less; show more than intended to earn a share, manage the risk of being over-filled on sweeps, cancel quickly when large orders appear, and care about minimum allocation thresholds and any top-order privilege, which brings the speed race back for the first order at a new price.

*What the interviewer is looking for: oversizing and its risk; the top-order step reintroducing speed.*

**Interview question 19.4 ★★ developer.**

Write [pro-rata allocation](#def-m1-matching-algorithms-and-implied-spreads-prorata) with a minimum lot size. What are the edge cases?

**Solution of Interview question 19.4.**

Compute $\lfloor a \cdot s_i / S\rfloor$ in integers for each order, on open quantities; drop allocations below the minimum; distribute the remainder by the secondary rule. Edge cases: aggressor larger than the level; total of floors less than the aggressor; all allocations below the minimum (then everything goes by the secondary rule); an order already partly filled by an earlier step; overflow of $a \cdot s_i$; never exceeding an order’s size; determinism of the tie-break. Test conservation on random books.

*What the interviewer is looking for: integer arithmetic, conservation, and the all-below-minimum case.*

**Interview question 19.5 ★★ researcher, mle.**

You only have [market-by-price](#def-m1-matching-algorithms-and-implied-spreads-mbo) data. How do you estimate your queue position in a FIFO book?

**Solution of Interview question 19.5.**

Record the level’s quantity when the order is acknowledged: that is the quantity ahead. Trades at the level reduce it one for one. Decreases without trades are cancellations: allocate them ahead and behind by an assumption (proportional, or all behind for a conservative estimate), bounded so that the quantity ahead never exceeds the level’s quantity minus one’s own order. Calibrate the assumption against one’s own fills: the realised fill times reveal the true position after the fact.

*What the interviewer is looking for: the bound from the level’s total, and calibration on own fills.*

**Interview question 19.6 ★★★ developer, researcher.**

You are building an exchange simulator for [calendar spreads](#def-m1-matching-algorithms-and-implied-spreads-calendar). What does implied matching force you to get right?

**Solution of Interview question 19.6.**

A single engine over all legs, since an update in any book can create or remove tradable quantity in the others; atomic multi-leg execution with leg prices assigned by the exchange’s convention; the rule ranking implied against direct orders at equal prices; no implied-against-implied; different ticks in spreads and outrights; the allocation algorithm of each book; and market data that reports implied quantity the way the real feed does, otherwise strategies trained on the simulator will see a book that does not exist.

*What the interviewer is looking for: cross-book event propagation and the ranking rule.*
