blog-cover-image

Citadel Quant Interview Questions

Quantitative interviews at top trading and investment firms like Citadel and Akuna Capital are renowned for their rigor and depth. They assess not only a candidate’s technical proficiency but also analytical thinking and problem-solving skills. In this article, we will delve into some representative quant interview questions from Citadel and Akuna Capital, providing detailed solutions, explanations of the underlying concepts, and optimal approaches to solving them.

Quant Interview Questions from Citadel and Akuna Capital


1. Output All Prime Numbers Smaller Than an Integer N (Citadel)

Understanding the Problem

Given a positive integer N, output all prime numbers less than N. The challenge lies in optimizing the solution, especially since N can be large.

What is a Prime Number?

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 2, 3, 5, 7, 11 are prime numbers.

Brute-Force Approach (Inefficient)

A naïve solution checks for each number from 2 to N-1 whether it is divisible by any number less than itself. However, this approach is inefficient for large N.

Optimal Solution: The Sieve of Eratosthenes

The Sieve of Eratosthenes is an efficient algorithm to generate all primes smaller than N. The idea is to iteratively mark the multiples of each prime starting from 2.

  • Create a boolean array is_prime[0 ... N-1].
  • Initialize all entries as true (assuming all numbers are prime).
  • Start from the first prime number, 2.
  • Mark all multiples of 2 as not prime.
  • Move to the next number and repeat until sqrt(N).
  • The remaining numbers marked as true are primes.

Python Implementation


def sieve_of_eratosthenes(n):
    if n <= 2:
        return []
    is_prime = [True] * n
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i]:
            for j in range(i*i, n, i):
                is_prime[j] = False
    primes = [i for i, prime in enumerate(is_prime) if prime]
    return primes

# Example usage:
N = 20
print(sieve_of_eratosthenes(N))

Time and Space Complexity

  • Time Complexity: \( O(N \log \log N) \)
  • Space Complexity: \( O(N) \)

Sample Output


[2, 3, 5, 7, 11, 13, 17, 19]

Key Takeaways

  • The Sieve of Eratosthenes is optimal for generating all primes less than N.
  • It significantly reduces the number of unnecessary checks.

2. Probability that X > Y, Where X ~ N(0,2), Y ~ N(0,1) (Citadel)

Understanding the Problem

Given two independent normal random variables:

  • \( X \sim N(0, 2) \) (mean 0, variance 2)
  • \( Y \sim N(0, 1) \) (mean 0, variance 1)

What is the probability \( P(X > Y) \)?

 

Key Concepts

  • Normal Distribution: A continuous probability distribution characterized by its mean (μ) and variance (σ²).
  • Difference of Normals: If X and Y are independent normal random variables, then \( Z = X - Y \) is also normal with \( \mu_Z = \mu_X - \mu_Y \) and \( \sigma_Z^2 = \sigma_X^2 + \sigma_Y^2 \).

Step-by-Step Solution

  1. Define \( Z = X - Y \).
  2. Then, \( Z \sim N(0 - 0, 2 + 1) = N(0, 3) \).
  3. We need \( P(X > Y) = P(Z > 0) \).
  4. For a normal random variable \( Z \sim N(0, 3) \), \( P(Z > 0) = 0.5 \) because it is symmetric about zero.

Mathematical Expression

\[ P(X > Y) = P(Z > 0) = \int_{0}^{\infty} \frac{1}{\sqrt{2\pi \cdot 3}} e^{-\frac{z^2}{2 \cdot 3}} dz \] But since the mean is 0, this is exactly 0.5.

Generalization

If the means were different, say \( X \sim N(\mu_X, \sigma_X^2) \), \( Y \sim N(\mu_Y, \sigma_Y^2) \), then: \[ P(X > Y) = P(Z > 0) = 1 - \Phi\left( \frac{0 - (\mu_X - \mu_Y)}{\sqrt{\sigma_X^2 + \sigma_Y^2}} \right ) \] Where \( \Phi \) is the standard normal cumulative distribution function (CDF).

Python Code Example


from scipy.stats import norm
import numpy as np

mu_x, sigma_x2 = 0, 2
mu_y, sigma_y2 = 0, 1

mu_z = mu_x - mu_y
sigma_z = np.sqrt(sigma_x2 + sigma_y2)

# Probability Z > 0
prob = 1 - norm.cdf(0, loc=mu_z, scale=sigma_z)
print(prob)  # Output: 0.5

Conclusion

  • Because both distributions are centered at zero, \( P(X > Y) = 0.5 \).
  • If the means differ, the probability can be found using the standard normal CDF.

3. Eigenvalues of the NxN Matrix With N on the Diagonal and 1 Everywhere Else (Citadel & Akuna Capital)

Understanding the Problem

Given an \( N \times N \) matrix \( A \) where each diagonal entry is \( N \) and all off-diagonal entries are 1, find all the eigenvalues of \( A \).

Matrix Representation

Let’s denote the matrix \( A \) as: \[ A = \begin{pmatrix} N & 1 & 1 & \dots & 1 \\ 1 & N & 1 & \dots & 1 \\ \vdots & \vdots & \ddots & \vdots & \vdots \\ 1 & 1 & 1 & \dots & N \end{pmatrix} \]

Decomposition of the Matrix

We can write \( A \) as: \[ A = (N - 1) I + J \] Where:

  • \( I \) is the \( N \times N \) identity matrix.
  • \( J \) is the \( N \times N \) matrix of all ones.

 

Finding the Eigenvalues

  • The eigenvalues of \( I \) are all 1.
  • The eigenvalues of \( J \) are \( N \) (once) and \( 0 \) (with multiplicity \( N-1 \)).
  • \( J v = N v \) for \( v = (1, 1, ..., 1) \), and \( J v = 0 \) for all \( v \) orthogonal to \( (1, ..., 1) \).

Since \( A = (N-1)I + J \), the eigenvalues of \( A \) are:

  • For \( v = (1, ..., 1) \): eigenvalue is \( (N-1) + N = 2N - 1 \).
  • For \( v \) orthogonal to \( (1, ..., 1) \): eigenvalue is \( (N-1) + 0 = N-1 \), with multiplicity \( N-1 \).

 

Final Answer

The eigenvalues of \( A \) are:

  • \( 2N - 1 \) (with multiplicity 1)
  • \( N - 1 \) (with multiplicity \( N - 1 \))

Verification for N = 3

For \( N = 3 \), the matrix is: \[ \begin{pmatrix} 3 & 1 & 1 \\ 1 & 3 & 1 \\ 1 & 1 & 3 \end{pmatrix} \] Eigenvalues are \( 5 \) (one time), and \( 2 \) (twice).

Summary Table

N Eigenvalue 1 Multiplicity Eigenvalue 2 Multiplicity
3 5 1 2 2
4 7 1 3 3
5 9 1 4 4

4. Calculating Gain/Loss of a Trading Strategy (Akuna Capital)

Understanding the Problem

Given a specific trading strategy and a list of stock prices throughout the day, calculate the total gain or loss at the end of the day. This type of question tests your ability to translate trading logic into code and your understanding of profit and loss calculations.

Example Strategy: "Buy Low, Sell High"

Suppose the strategy is to buy whenever the price dips below a moving average and sell when it rises above. For simplicity, we’ll use a simple trading rule:

  • Buy at the first price (open position).
  • Sell at the last price (close position at end of day).

 

Sample Input and Output


Prices = [100, 102, 101, 105, 110, 108]

If we buy at 100 and sell at 108, the gain is 8.

Python Implementation


def simple_gain(prices):
    if not prices:
        return 0
    buy_price = prices[0]
    sell_price = prices[-1]
    return sell_price - buy_price

# Example usage:
prices = [100, 102, 101, 105, 110, 108]
print(simple_gain(prices))  # Output: 8

Advanced Example: Multiple Trades

Let’s consider a strategy where you buy at every local minimum and sell at every local maximum.


def multi_trade_gain(prices):
    n = len(prices)
    if n < 2:
        return 0
    gain = 0
    for i in range(1, n):
        if prices[i] > prices[i - 1]:
            gain += prices[i] - prices[i - 1]
    return gain

# Example usage:
prices = [100, 102, 101, 105, 110, 108]
print(multi_trade_gain(prices))  # Output: 14

Here, we sum all increments, simulating buying before every rise and selling at every peak.

Explanation of Results

  • Simple gain: Measures profit from buying at open and selling at close.
  • Multiple trade gain: Sums up all positive price differences, simulating optimal trading.

Generalization

You can adapt the approach to more complex strategies, such as those involving moving averages, stop-loss orders, or volume-weighted execution.


Conclusion

Quantitative interviews at Citadel and Akuna Capital are designed to rigorously test both mathematical and programming skills. Key abilities include efficient algorithm design (as in finding primes), deep understanding of probability and linear algebra (as in probability and eigenvalue problems), and the ability to translate trading ideas into code. Mastering these concepts and practicing similar problems is crucial for success in elite quant interviews.

Related Articles