Citadel SWE Interview Sharing|Order Book Design + Behavioral Digging

40 Views
No Comment

I recently reviewed a game Citadel To be honest, the overall intensity of the SWE interview was quite real. It's not a fancy and tricky question, but every step is very close to the actual trading system scenario. Coding is more engineering-minded, and Behavioral is also very deep. If you only prepare according to the question-answering idea, it will be somewhat difficult. Let’s talk by module.

Citadel SWE Interview Sharing|Order Book Design + Behavioral Digging

Coding: Order Book Design

This question is a simplified version of order book design. The input data contains four fields: exchange_id, price, quantity, order_type (bid or ask). It is required to design a class to support real-time insertion of orders and implement two core methods.

The first one is get_exchange_bbo. Pass in an exchange_id and return the current highest buying price and lowest selling price of this exchange.

The second one is get_nbbo. Returns the highest buying price and lowest selling price in the entire market, which is the best quote from all exchanges combined.

This type of question is not difficult in nature. The key is how you choose the data structure and whether it is close to the real scenario.

Idea:

The core is to design the structure around "how to quickly get the best buying and selling prices." Because there are multiple exchanges, you can first use a HashMap to group by exchange_id, and each exchange corresponds to an independent OrderBook. Each OrderBook is internally divided into two parts: buy orders and sell orders: buy orders are maintained using MaxHeap, and the top of the heap is the highest bid price; sell orders are maintained using MinHeap, and the top of the heap is the lowest selling price. In this way, order insertion is O(log N), and querying the optimal quote of a single exchange is O(1).

Get_exchange_bbo only needs to read the tops of the two heaps of the corresponding exchanges; get_nbbo traverses the optimal buying and selling prices of all exchanges and selects the global highest and lowest, with a complexity of O(E). Because the number of exchanges is usually small, this step is very expensive. If the interviewer asks about extended scenarios, such as order cancellation or modification, Heap can be added to make it inconvenient to delete intermediate elements. In actual projects, TreeMap or red-black tree can be used to support O(log N) insertion and deletion. This kind of trade-off thinking will be a bonus.

Behavioral link

This round is actually quite critical. It lasts about twenty minutes and the intensity of questioning is quite high. The interviewer will dig deeper around the resume, such as why did you choose this technology instead of another? What is the biggest bottleneck of the system? How to locate the problem at that time? Have other options been evaluated?

Ownership is the key. They will judge whether you are a core participant through detailed questions. If the project is not really led by oneself, the secret will be revealed after a few rounds of questioning. Technical depth is also important. Do you really understand the system you have worked on, instead of just staying on the surface? Another point is expressive ability. Whether you can explain complex systems clearly and understand your design ideas in relatively straightforward terms has a great impact.

Overall feeling

Coding is not difficult, but it is very engineering. It is not a routine question type, but a real system modeling. Behavioral is quite stressful, especially when you are asked about continuous details. You need to have a clear mind and not be confused.

If you are preparing for Citadel SWE or HFT/trading system related positions recently, it is recommended to sort out the basic structure of Order Book, matching logic, and data structure trade-off. Engineering thinking is really more important than the number of questions. If you need more real questions or want to know about interview assistance services, please Contact us.

author avatar
Jory Wang Amazon Senior Software Development Engineer
Amazon senior engineer, focusing on the research and development of infrastructure core systems, with rich practical experience in system scalability, reliability and cost optimization. Currently focusing on FAANG SDE interview coaching, helping 30+ candidates successfully obtain L5/L6 Offers within one year.
END
 0