Compute Fill Markouts Against Future Mid Prices in Pandas

Last updated: November 29, 2026

Quick Overview

Given a table of the firm's fills and a table of top-of-book quotes, compute each fill's signed markout (mid price at t plus 100 ms, 1 s and 5 s minus fill price) and summarize quantity-weighted markouts per symbol.

Imc
Data Manipulation (SQL/Python)
Data Scientist
Imc
November 29, 2026
Data Scientist
Take-home Project
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given a table of the firm's fills and a table of top-of-book quotes, compute each fill's signed markout (mid price at t plus 100 ms, 1 s and 5 s minus fill price) and summarize quantity-weighted markouts per symbol.

Markouts are how a market maker like IMC measures whether its fills are profitable or adversely selected, and researchers compute them constantly when tuning quoting strategies. The interviewer checks as-of joins without look-ahead bias, sign conventions for buys and sells, and sensible aggregation.

What the Interviewer Expects
  • Uses an as-of (backward) join so each probe uses the last known quote
  • Applies sign so positive always means the fill made money
  • Joins per symbol
  • Weights the summary by quantity
  • Validates with a hand-computed fill
  • Mentions look-ahead and stale-quote risks
Key Topics to Cover
merge_asof
markouts
adverse selection
time series joins
pandas
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you do this for 500 million fills that do not fit in memory?
  • Why might you mark against a microprice instead of the mid?
  • How would you split markouts by whether the fill was passive or aggressive?
  • What does a positive 100 ms markout but negative 5 s markout tell you?
Sharpen Your Skills on Codemia

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

Practice SQL Problems
Sample Answer
Clarify the Data

fills: time, symbol, side ('B'/'S'), qty, price. quotes: time, symbol, bid, ask, one row per top-of-book change. Times are timestamps on the same clock. Markout for horizon h: `sign * (mid(t +...

Approach

Compute mid on quotes. For each horizon, shift fill times by h, then merge_asof on time with by='symbol' and direction='backward', which is exactly the last quote known at that moment. Keep the ...


Submit Your Answer
Markdown supported

Related Questions