DEV Community

Cover image for Optiver OA (Dec 4, 2025) — Full Breakdown of the 3 Coding Problems
net programhelp
net programhelp

Posted on

Optiver OA (Dec 4, 2025) — Full Breakdown of the 3 Coding Problems

Optiver's Online Assessment is renowned for its demands on "speed + accuracy," and the December 4, 2025 version stays true to form: 3 coding questions all centered on trading simulations. The volume of code required isn’t massive, but the logic is full of pitfalls; missing even a single edge case can lead to failure.

Here is a breakdown of the core test points and problem-solving tips to help you navigate the assessment smoothly.

1. Counting Trading Sequences

Problem Statement
Given a price sequence, count all valid profitable trading pairs (i, j) where i < j and price[i] < price[j]. Essentially, it’s about finding increasing pairs, but there are critical caveats.

Key Pitfalls & Solutions

  • Duplicate prices are invalid: A strictly increasing relationship is required.
  • Descending intervals matter: Consecutive descending intervals affect statistical logic and must be handled correctly.
  • Ignore short sequences: Sequences of length 1 must be ignored.
  • Time Complexity: A brute-force O(n^2) approach will definitely time out. You must use an O(n log n) method, generally involving "maintaining the count of smaller prefix elements" (often solved using a Fenwick Tree/Binary Indexed Tree or modified Merge Sort).

2. Backtesting a Proportional Allocation Strategy

Problem Statement
Given daily returns for multiple assets and a fixed proportional allocation vector representing portfolio weights, calculate the cumulative return of the portfolio from day 1 to day N.

The core formula involved is: daily portfolio return = sum(weight[i] * returns[day][i]). Crucially, calculating the cumulative return requires multiplication over time, not summation.

Key Pitfalls & Solutions

  • Floating-point error is fatal! This is the biggest trap. Using Python’s default float type will result in precision errors, causing you to get stuck at roughly 89% of test cases passing.
  • Solution: You must switch to the Decimal type for daily cumulative calculations to pass all hidden tests. Both weights and returns are given as decimals, and insufficient precision directly triggers failures.

3. Order Book Matching Simulation

Problem Statement
Process a list of incoming buy/sell orders (each containing type, price, and size), simulate a two-way order book, and return all unmatched orders after processing.

Matching Rules:

  1. Buy orders prioritize matching with the cheapest available sell orders.
  2. Sell orders prioritize matching with the most expensive available buy orders.
  3. Orders at the exact same price must follow FIFO (First-In, First-Out) logic based on arrival time.
  4. Partial matching is supported: If an order is partially filled, the remaining size stays in the book (or continues trying to match). Only leftover sizes are added to the book at the end of a matching attempt.

Key Pitfalls & Solutions

  • Handle partial matches correctly: Don’t break your loop immediately after a partial match. You must continue looping until the current incoming order's size reaches zero or no matching orders remain.
  • Maintain FIFO: Orders at the same price must strictly maintain chronological order.
  • Clean up completed orders: Remove order nodes immediately when their size reaches 0 after matching.
  • Sorting is critical: Wrong ordering ruins everything.
    • The Buy book must be sorted from highest to lowest price.
    • The Sell book must be sorted from lowest to highest price.

Summary: Core Info of Optiver OA 3 Problems

| Problem | Type | Difficulty | Core Test Points |
| P1 | Sequence Counting | Medium | Monotonic Logic + Boundary Handling |
| P2 | Portfolio Backtesting | Medium-High | Floating-Point Precision (Decimal) + Cumulative Calculation |
| P3 | Order Book Simulation | High | Trading System Logic + Queue (FIFO) + Sorting Strategy |

Conclusion

Optiver’s New Grad total compensation package typically ranges from $200k to $300k, arguably making this OA one of the "most valuable exams" of your career. If you get stuck, consider real-time support from mentors with Ex-FAANG and Quant backgrounds—it’s not ghostwriting, but guidance to clarify logic, avoid pitfalls, and adjust code style to match your past habits, evading plagiarism checks. Many have aced all three questions in 50 minutes with this approach, maximizing efficiency.

Top comments (0)