FastPrepTrack the Book and Mark Final PnL
Problems/Track the Book and Mark Final PnL

Track the Book and Mark Final PnL

Millennium logoMillennium● MediumNEW GRADINTERNOA

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a Millennium online assessment for new grad and intern roles. The report gives the signs for the client's cash and inventory, and the final mark-to-market PnL. It leaves out the table schema, what an empty book does, and the exact rules for decimals and number limits. We set limits on quantity, price scale, and total notional. They keep cancellation exact in every supported language and do not change the book update in the report.

Our version is about 90% the same as the reported question.

A market-making desk fills client requests and tracks its cash and inventory. Every row in fills is one completed client trade.

Book updates

  • For a client BUY, the desk sells the quantity: desk inventory decreases and cash increases by quantity * fill_price.
  • For a client SELL, the desk buys the quantity: desk inventory increases and cash decreases by quantity * fill_price.

The closing_prices table represents the final price row, with exactly one closing mark for every traded asset. After all fills, compute pnl = cash + sum(inventory[asset] * mark_price[asset]).

Return exactly one row with the column pnl.

Table schema

MySQLPostgreSQLPandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

fills

ColumnTypeNullableDescription
fill_idPKIntegerNo—
assetTextNo—
client_sideTextNo—
quantityIntegerNo—
fill_priceDecimalNo—

closing_prices

ColumnTypeNullableDescription
assetTextNo—
mark_priceDecimalNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
pnlDecimalNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • 0 <= fills.row_count <= 2000.
  • Every fill_id is unique.
  • Every client_side is exactly BUY or SELL.
  • Every quantity is an integer in [1, 1000000].
  • Every fill and closing price is an exact decimal in (0, 1000000000000] with at most 6 fractional digits.
  • closing_prices contains exactly one row for each asset that occurs in fills; it may also contain untraded assets.
  • Each fill notional is at most 10^18; the absolute cash and marked-inventory totals are each at most 2 * 10^21, and |pnl| <= 4 * 10^21. These bounds keep every exact intermediate and result within the shared DECIMAL(38, 12) / 38-digit decimal runtime contract.
  • Use exact decimal arithmetic and return 0 when there are no fills.

More Millennium Online Assessment questions

  • Calculate the Half SpreadOA · Seen Sep 2026
  • Debug the Impact ModelOA · Seen Sep 2026
  • Debug the Risk-Limit QuoterOA · Seen Sep 2026
  • Hedge Inventory with Return CovarianceOA · Seen Sep 2026
  • Quote One RequestOA · Seen Sep 2026
  • Risk Limits and Inventory SkewOA · Seen Sep 2026
  • Clean the TapeOA · Seen Sep 2026
  • Client Markout AnalysisOA · Seen Sep 2026
  • Debug Fair-Value LookupOA · Seen Sep 2026
  • Debug the Tape CleanerOA · Seen Sep 2026

Similar questions at other companies

  • Process Airline Seat RequestsAgoda · OAAgoda interview questions
  • In-Memory Database Historical LookupAnthropic · OAAnthropic interview questions
  • Nested Transaction Key-Value Store with Value CountsLyft · ONSITE INTERVIEWLyft interview questions
  • Parquet-Like Columnar Format OperationsJump Trading · PHONE SCREENJump Trading interview questions
  • Assign Student Grades from CSV MarksHartford Financial Services · ONSITE INTERVIEWHartford Financial Services interview questions
  • Bold Play to Reach a GoalSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Request Routing SystemStripe · OAStripe interview questions
  • Auction Lot Bid SummaryHackerRank · OAHackerRank interview questions
  • Simulate Orchard Rot SpreadAirbnb · OAAirbnb interview questions
  • Simulate Orchard Rot SpreadCapital One · OACapital One interview questions

Millennium interview experiences

  • Millennium Full Stack Engineer Java Interview: 1 Experience
All Millennium interview questionsSee Millennium hiring insights