PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Optiver

Maintain Price Levels For A Single-Symbol Order Book

Last updated: Jul 9, 2026

Quick Overview

Review a single-symbol order book implementation prompt with insert, modify, cancel, and price-level lookup callbacks. The interview topic focuses on side-specific best prices, aggregating quantities by price, active order tracking, and stateful API design.

  • medium
  • Optiver
  • Coding & Algorithms
  • Software Engineer

Maintain Price Levels For A Single-Symbol Order Book

Company: Optiver

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a simplified NASDAQ market data book for one symbol. You receive callbacks when orders are inserted, modified, or canceled. Each order has an id, side, price, and quantity. Implement `GetPriceLevel(side, level_index)`, where level 0 is the best price: highest price for buy orders and lowest price for sell orders. Return the price and total quantity at that price level. Function signature: ```python class OrderBook: def on_order_insert(self, order_id: int, side: str, price: int, qty: int) -> None: pass def on_order_modify(self, order_id: int, price: int, qty: int) -> None: pass def on_order_cancel(self, order_id: int) -> None: pass def get_price_level(self, side: str, level_index: int) -> tuple[int, int] | None: pass ``` Constraints: - `side` is either `'buy'` or `'sell'`. - Order ids are unique while active. - Modifying an order may change both price and quantity. - Canceling an unknown order should be handled gracefully or specified as invalid. - If the requested level does not exist, return `None`. Examples: ```text Insert buy id 1 price 100 qty 5; insert buy id 2 price 101 qty 3. get_price_level('buy', 0) returns (101, 3). ``` ```text Insert sell id 3 price 105 qty 2; insert sell id 4 price 105 qty 7. get_price_level('sell', 0) returns (105, 9). ```

Quick Answer: Review a single-symbol order book implementation prompt with insert, modify, cancel, and price-level lookup callbacks. The interview topic focuses on side-specific best prices, aggregating quantities by price, active order tracking, and stateful API design.

Related Interview Questions

  • Build and Validate a Binary Tree from Parent-Child Pairs - Optiver (medium)
  • Days Between Two Calendar Dates - Optiver (medium)
  • Thread-Safe Stock Inventory: Buy and Sell Without Overselling - Optiver (medium)
  • Implement a Level-Aware Expiring Inventory Store - Optiver (medium)
  • Find missing numbers in sequences - Optiver (hard)
|Home/Coding & Algorithms/Optiver

Maintain Price Levels For A Single-Symbol Order Book

Optiver logo
Optiver
Jun 26, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
16
0

Implement a simplified NASDAQ market data book for one symbol. You receive callbacks when orders are inserted, modified, or canceled. Each order has an id, side, price, and quantity. Implement GetPriceLevel(side, level_index), where level 0 is the best price: highest price for buy orders and lowest price for sell orders. Return the price and total quantity at that price level.

Function signature:

class OrderBook:
    def on_order_insert(self, order_id: int, side: str, price: int, qty: int) -> None:
        pass

    def on_order_modify(self, order_id: int, price: int, qty: int) -> None:
        pass

    def on_order_cancel(self, order_id: int) -> None:
        pass

    def get_price_level(self, side: str, level_index: int) -> tuple[int, int] | None:
        pass

Constraints:

  • side is either 'buy' or 'sell' .
  • Order ids are unique while active.
  • Modifying an order may change both price and quantity.
  • Canceling an unknown order should be handled gracefully or specified as invalid.
  • If the requested level does not exist, return None .

Examples:

Insert buy id 1 price 100 qty 5; insert buy id 2 price 101 qty 3. get_price_level('buy', 0) returns (101, 3).
Insert sell id 3 price 105 qty 2; insert sell id 4 price 105 qty 7. get_price_level('sell', 0) returns (105, 9).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Optiver•More Software Engineer•Optiver Software Engineer•Optiver Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.