FastPrepWorst Trade Reporter
Problems/Worst Trade Reporter

Worst Trade Reporter

Optiver logoOptiver● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optiver online assessment. The loss-per-lot rule, the tie-break, the examples, and the constraints match the report at about 99%. The original used a callback. Here the function returns the whole batch result instead.

Process a stream of price updates, trades, and worst-trade queries.

  • PRICE instrument price sets the latest true price for an instrument.
  • TRADE tradeId instrument BUY|SELL price volume records a unique trade.
  • WORST_TRADE instrument asks for the recorded trade with the greatest loss per lot at the latest true price.

For a buy, profit per lot is truePrice - tradePrice. For a sell, profit per lot is tradePrice - truePrice. A trade is bad only when this value is negative. If several trades have the same greatest loss per lot, choose the one that appeared latest in the instruction stream. If no trade is bad, return NO BAD TRADES.

Return one string for every query, in query order.

Function

worstTrades(instructions: String[]) → String[]

Examples

Example 1

instructions = ["PRICE Facebook 80","PRICE Apple 120","TRADE 100 Apple SELL 90 2","TRADE 10 Facebook BUY 100 4","WORST_TRADE Facebook","WORST_TRADE Apple"]return = ["10","100"]

The Facebook buy loses 20 per lot, while the Apple sell loses 30 per lot.

Example 2

instructions = ["PRICE Google 100","TRADE 1 Google BUY 100 10","WORST_TRADE Google","TRADE 2 Google SELL 102 5","TRADE 3 Google SELL 103 5","PRICE Google 98","WORST_TRADE Google","TRADE 4 Google BUY 101 10","TRADE 5 Google BUY 100 10","WORST_TRADE Google"]return = ["NO BAD TRADES","1","4"]

The first query has no loss. At price 98, trade 1 loses 2 per lot; after two more buys, trade 4 loses 3 per lot.

Constraints

  • 1 <= instructions.length <= 10^6
  • 1 <= tradeId, price, volume <= 10^6
  • Every trade ID is unique.
  • A price update for an instrument appears before its first trade or query.
  • Instrument identifiers contain no spaces.

More Optiver Online Assessment questions

  • Chance a Die Game Balance Reaches ZeroOA · Seen Dec 2026
  • Chance a Hand of Cards Multiplies to More Than a ThresholdOA · Seen Dec 2026
  • Chance a Sum of Random Draws Has a Given Number of DigitsOA · Seen Dec 2026
  • Expected Draws to Remove All Green CountersOA · Seen Dec 2026
  • Expected Profit of a Doubling Betting SystemOA · Seen Dec 2026
  • Expected Steps Until a Random Walk Gets Far From ZeroOA · Seen Dec 2026
  • Rolling Until One Face's Own Total Passes a ThresholdOA · Seen Dec 2026
  • Two Ranked Teams Meeting in a Random BracketOA · Seen Dec 2026
  • Overheat Prevention ControllerOA · Seen Nov 2026
  • Power Cell BankOA · Seen Nov 2026

Similar questions at other companies

  • Split Tender Part 2 - Expiration DatesStripe · OAStripe interview questions
  • Organization Reputation After Employee DeparturesHSBC · OAHSBC interview questions
  • Expiring Authentication Token ManagerIBM · OAIBM interview questions
  • Progressive Banking SystemAirbnb · OAAirbnb interview questions
  • Named Async Task SchedulerAirwallex · OAAirwallex interview questions
  • Weighted LFU CacheIMC Trading · OAIMC Trading interview questions
  • Weighted LFU CacheMicrosoft · OAMicrosoft interview questions
  • Cloud Compute Credits SystemCoinbase · OACoinbase interview questions
  • Assign Server Numbers by TypeOura · OA
  • Get Priorities after Execution 🥭Amazon · OA

Optiver interview experiences

  • Optiver SWE Intern OA: CPU Temperature Simulation: 1 Experience
  • Optiver Trading Intern Market-Making Games: 1 Experience
  • Optiver Quant Trader Intern Technical Interview: 1 Experience
  • Optiver SWE Intern System Design Interview: 15 Experiences
All Optiver interview questionsSee Optiver hiring insights
Saved
class Solution {
    public String[] worstTrades(String[] instructions) {
      // write your code here
    }
}
Checking account…