Level 3 — ProductionOrder Types & Mechanics

Order Types & Mechanics

45 minutes60 marksprintable — key stays hidden on paper

Level 3: Production (from-scratch derivations, code-from-memory, explain-out-loud)

Time limit: 45 minutes Total marks: 60

Instructions: Show all working. For "explain-out-loud" prompts, write as if teaching a peer. Use ...... for any math.


Q1. [10 marks] — Matching engine from memory A continuous limit order book uses price-time priority. The current book is:

| BIDS (buy) | | ASKS (sell) | | |---|---|---| | Price | Qty | Price | Qty | | 100.50 | 200 | 100.60 | 150 | | 100.40 | 300 | 100.70 | 400 | | 100.30 | 500 | 100.80 | 250 |

(a) A market buy order for 500 shares arrives. Walk through the matching engine step by step, stating the fill price(s), quantities, and the resulting average execution price. (6) (b) After this fill, state the new best bid, best ask, and the bid-ask spread. (2) (c) Explain out loud why time priority matters when two resting orders sit at the same price. (2)


Q2. [12 marks] — Order-type decision logic (code-from-memory) Write pseudocode (or Python) for a function route_order(order) that, given an order with fields type ∈ {MARKET, LIMIT, IOC, FOK}, side, qty, limit_price, and access to a function available_qty_at_or_better(side, price), decides the fill outcome. Requirements: (a) MARKET fills at best available. (2) (b) LIMIT fills only at limit_price or better; unfilled remainder rests on the book. (3) (c) IOC fills whatever is immediately available then cancels the rest. (3) (d) FOK fills fully or cancels entirely (all-or-nothing, immediate). (3) Add a one-line comment stating the key difference between IOC and FOK. (1)


Q3. [10 marks] — Slippage & average fill derivation A trader places a market buy for 1000 shares. The ask ladder is:

  • 250 @ 50.1050.10
  • 300 @ 50.1550.15
  • 600 @ 50.2550.25

(a) Derive the total cost and the volume-weighted average fill price. (4) (b) The trader expected to pay the best ask (50.1050.10). Compute the slippage per share and total slippage in dollars. (3) (c) Explain out loud how a limit order would have changed this outcome, and the trade-off involved. (3)


Q4. [10 marks] — Bracket & stop orders from scratch A trader buys 100 shares at \420intradayandsetsabracketorderwithatargetofintraday and sets a **bracket order** with a target of+2%andastoplossofand a stop-loss of-1%$. (a) Compute the target price and stop-loss trigger price. (3) (b) Compute the profit if the target hits, and the loss if the stop hits (ignore fees). (3) (c) Explain the difference between a stop-loss (market) and a stop-limit order, and describe one scenario where a stop-limit fails to execute. (4)


Q5. [10 marks] — Circuit limits & pre-open call auction (a) A stock closed yesterday at \200withawith a10%$ price band. Compute today's upper and lower circuit prices. (2) (b) In the pre-open session, the following orders exist:

Buy Qty Price Sell Qty
500 201 100
300 200 400
200 199 600

Explain out loud how the equilibrium (call auction) price is determined by the principle of maximum executable quantity, and identify which price maximizes matched volume. (6) (c) State what happens to the residual unmatched orders when continuous trading begins. (2)


Q6. [8 marks] — Level-1 quote reading & GTT/AMO concepts A Level-1 quote shows: LTP 305.20 | Bid 305.10 × 400 | Ask 305.30 × 250 | Vol 1.2M. (a) Interpret each field in one sentence. (4) (b) You want to buy only if the price falls to \290$ next week without keeping the order active daily. Which order type (GTT vs AMO vs day limit) fits, and why? (2) (c) Explain out loud one key mechanical difference between a GTT order and an AMO. (2)

Answer keyMark scheme & solutions

Q1 (10)

(a) Market buy consumes asks by price-time priority (lowest ask first):

  • Fill 150 @ 100.60 → cost 150×100.60=15090150 \times 100.60 = 15090
  • Remaining 350; fill 350 @ 100.70 → cost 350×100.70=35245350 \times 100.70 = 35245 (2 marks: correct ladder walk)
  • Total qty = 500, total cost =15090+35245=50335= 15090 + 35245 = 50335 (2 marks)
  • Average price =50335/500=100.67= 50335 / 500 = 100.67 (2 marks)

(b) Best ask now = 100.70 (with 50 left) — since 350 of the 400 were consumed. Best bid unchanged = 100.50. Spread =100.70100.50=0.20= 100.70 - 100.50 = 0.20. (2 marks)

(c) At equal price, the order that arrived first is filled first. This rewards earlier commitment, prevents queue-jumping, and makes the book deterministic/fair. (2 marks)


Q2 (12)

Sample answer:

def route_order(order):
    avail = available_qty_at_or_better(order.side, order.limit_price)
    if order.type == "MARKET":
        return fill(order.qty, at="best")            # (a) 2
    if order.type == "LIMIT":
        f = min(order.qty, avail)
        fill(f, at=order.limit_price)
        rest = order.qty - f
        if rest > 0: place_on_book(rest, order.limit_price)  # (b) 3
        return
    if order.type == "IOC":
        f = min(order.qty, avail)
        fill(f, at=order.limit_price)
        cancel(order.qty - f)                          # (c) 3
        return
    if order.type == "FOK":
        if avail >= order.qty:
            fill(order.qty, at=order.limit_price)      # (d) 3
        else:
            cancel(order.qty)                          # all-or-nothing
    # KEY DIFF: IOC allows partial fill then cancels rest;
    # FOK requires full fill immediately or cancels everything. (1)

Award marks for correct behaviour per branch even if syntax differs.


Q3 (10)

(a) Fills: 250×50.10=12525250 \times 50.10 = 12525; 300×50.15=15045300 \times 50.15 = 15045; 450×50.25=22612.5450 \times 50.25 = 22612.5 (only 450 of last tier needed for 1000). (2) Total cost =12525+15045+22612.5=50182.5= 12525 + 15045 + 22612.5 = 50182.5. VWAP =50182.5/1000=50.1825= 50182.5 / 1000 = 50.1825. (2)

(b) Expected cost at best ask =1000×50.10=50100= 1000 \times 50.10 = 50100. Slippage total =50182.550100=82.5= 50182.5 - 50100 = 82.5. (2) Per share =82.5/1000=0.0825= 82.5 / 1000 = 0.0825. (1)

(c) A limit buy at 50.1050.10 would fill only the 250 available there (partial fill), guaranteeing price but not quantity. Trade-off: limit protects against slippage but risks non-execution / partial fill; market guarantees fill but not price. (3)


Q4 (10)

(a) Target =420×1.02=428.40= 420 \times 1.02 = 428.40. Stop =420×0.99=415.80= 420 \times 0.99 = 415.80. (3) (b) Profit if target =(428.40420)×100=840= (428.40 - 420) \times 100 = 840. Loss if stop =(420415.80)×100=420= (420 - 415.80) \times 100 = 420. (3) (c) Stop-loss (market): once trigger hit, sends a market order — guaranteed execution, price may slip in fast markets. Stop-limit: sends a limit order at a set price — protects price but may not fill if price gaps below the limit (e.g., stock trigger at 415.80, limit 415.50, but price plunges to 414 skipping the range → order rests unfilled). (4)


Q5 (10)

(a) Upper =200×1.10=220= 200 \times 1.10 = 220; Lower =200×0.90=180= 200 \times 0.90 = 180. (2) (b) Call auction picks the price maximizing matched (executable) volume. Cumulative buy demand (bids at ≥ price) vs cumulative sell supply (asks at ≤ price):

Price Cum Buy (≥P) Cum Sell (≤P) Matched = min
201 500 100 100
200 800 500 500
199 1000 1100 1000

Maximum matched volume = 1000 at price 199. Equilibrium price = 199 (maximizes tradeable quantity). (6 — award for method + correct answer) (c) Unmatched residual orders (e.g., excess sell supply at 199) are carried forward into continuous trading and rest on the order book at their limit prices. (2)


Q6 (8)

(a) LTP = last traded price (305.20305.20); Bid = best buy price 305.10305.10 for 400 shares; Ask = best sell price 305.30305.30 for 250 shares; Vol = cumulative shares traded today (1.2M). (4) (b) GTT — it stays valid for weeks/months and triggers only when price hits \290$, without daily re-entry. AMO only queues for next session; a day limit expires end of day. (2) (c) GTT persists across days and fires on a price trigger condition; an AMO is a one-shot order placed after hours that queues for the next session's open and does not persist beyond it. (2)

[
  {"claim":"Q1 average fill price = 100.67","code":"cost=150*100.60+350*100.70; result=abs(cost/500-100.67)<1e-9"},
  {"claim":"Q3 VWAP = 50.1825","code":"cost=250*50.10+300*50.15+450*50.25; result=abs(cost/1000-50.1825)<1e-9"},
  {"claim":"Q3 total slippage = 82.5","code":"cost=250*50.10+300*50.15+450*50.25; result=abs(cost-1000*50.10-82.5)<1e-9"},
  {"claim":"Q4 target/stop and P/L","code":"tgt=420*Rational(102,100); stp=420*Rational(99,100); result=(tgt==Rational(4284,10)) and ((tgt-420)*100==840) and ((420-stp)*100==420)"},
  {"claim":"Q5 circuits 220/180","code":"result=(200*Rational(110,100)==220) and (200*Rational(90,100)==180)"},
  {"claim":"Q5 max matched volume = 1000 at price 199","code":"m={201:min(500,100),200:min(800,500),199:min(1000,1100)}; best=max(m,key=lambda p:m[p]); result=(best==199 and m[best]==1000)"}
]