← 返回博客列表
Optiver

Optiver 2024 Campus Software Engineer Test Questions

2025-10-22

Optiver 2024 Campus Recruitment Software Engineer Test Questions. oavoservice shares complete questions and high-frequency topics to help you prepare for interviews at quantitative trading firms.

📋 Question 1: Order Book Implementation

Implement a simplified Order Book data structure.

Core Features

import heapq
from collections import defaultdict

class OrderBook:
    def __init__(self):
        self.bids = []  # Buy orders (Max Heap)
        self.asks = []  # Sell orders (Min Heap)
        self.orders = {}  # {order_id: order_info}
    
    def add_order(self, order_id, side, price, quantity):
        order = {
            'id': order_id,
            'side': side,
            'price': price,
            'quantity': quantity
        }
        
        self.orders[order_id] = order
        
        if side == 'buy':
            heapq.heappush(self.bids, (-price, order_id))
        else:
            heapq.heappush(self.asks, (price, order_id))
    
    def cancel_order(self, order_id):
        if order_id in self.orders:
            del self.orders[order_id]
            return True
        return False
    
    def get_best_bid(self):
        while self.bids:
            price, order_id = self.bids[0]
            if order_id in self.orders:
                return -price
            heapq.heappop(self.bids)
        return None
    
    def get_best_ask(self):
        while self.asks:
            price, order_id = self.asks[0]
            if order_id in self.orders:
                return price
            heapq.heappop(self.asks)
        return None
    
    def get_spread(self):
        best_bid = self.get_best_bid()
        best_ask = self.get_best_ask()
        
        if best_bid and best_ask:
            return best_ask - best_bid
        return None

📋 Question 2: Market Data Analysis

Calculate moving average and volatility.

Implementation

from collections import deque

class MarketDataAnalyzer:
    def __init__(self, window_size):
        self.window_size = window_size
        self.prices = deque(maxlen=window_size)
    
    def add_price(self, price):
        self.prices.append(price)
    
    def get_moving_average(self):
        if not self.prices:
            return None
        return sum(self.prices) / len(self.prices)
    
    def get_volatility(self):
        if len(self.prices) < 2:
            return None
        
        mean = self.get_moving_average()
        variance = sum((p - mean) ** 2 for p in self.prices) / len(self.prices)
        return variance ** 0.5

💼 How oavoservice Helps

Quant Knowledge - Order Book and Market Data Data Structures - Applications of Heaps and Queues Performance Optimization - High-frequency Trading Scenarios

Contact oavoservice for professional Quant interview assistance!


Tags: #Optiver #QuantTrading #OrderBook #OA #OAHelp #InterviewPrep #1point3acres


Need real interview questions? Contact WeChat Coding0201 immediately to get real questions.