AI in Finance Interview Questions to Watch Out For

What do you need to know if you are interested in ML and Finance?

Landing a job in quantitative trading is not easy as it usually require a PhD. It's not impossible to get a gig as a quant without a Ph.D. though, just harder. This is just the inherent bias in the industry, it is usually very hard to find talent - because strong engineers or scientist in this field have to hold solid programming, maths, statistics and finance skills. There are not too many people available in the world who can fulfill these requirements. This blog post is meant to get you acquainted with the type of questions you can expect to deal during an interview to make an idea whether this domain is really for you, or not!

The following questions were asked during a real quant interview. It comprises of 12 questions from the field of finance, statistics and game theory. My own solutions are also provided, though I did have to research some in order to get them right.

1. A stock has beta of 2.0 and stock specific daily volatility of 2%. Suppose that yesterdays closing price was $ 100 and today the market goes up by 1%. Whats the probability of todays closing price being at least $ 103? Whats the probability that the closing price is at least $ 110?

Solution

This is a great first question to start as we can remind some useful finance terminologies.
Beta is a measure used in fundamental analysis to determine the volatility of an asset or portfolio in relation to the overall market. The overall market (let's say S & P 500) has a beta of 1.0, and individual stocks (let's say AAPL which is in that index) are ranked according to how much they deviate from the market.
Beta is mathematically defined as: $ \beta= \dfrac{Covariance}{Variance} $.

Covariance measures how two stocks (or a stock and a market) move together. In the above formula, it's a measure of a stocks return relative to that of the market.

A positive covariance means the stocks tend to move together when their prices go up or down. A negative covariance means the stocks move opposite of each other.

Variance, on the other hand, refers to how far a stock moves relative to its mean.

Variance is used in measuring the volatility of an individual stock's price over time. Covariance is used to measure the correlation in price moves of two different stocks.

Now to answer the question:

We need to model stock returns for this. These are assumed to be normally distributed: $$RN(μ,σ)$$ If the overall market goes up by $1\%$, then the expected stock return can be calculated (by definition) with the help of beta: $$μ = \beta \cdot 0.01 = 0.02$$ Note that, from the problem statement (the volatility being $2\%$): $$ σ=0.02 $$ Therefore: $$RN(0.02,0.02)$$ Stock price going from 100 to over 103 requires a return of at least $3\%$. Converting this into probabilities, the problem is asking for $$P(R \ge 0.03)$$ This is equal to: $$1 - P(R \le 0.03) = 1 - \Phi(\dfrac{0.03 - μ}{σ}) = 1 - \Phi(0.5) = 0.31$$ So, the probability that todays closing price being at least $ 103 is $31\%$.

It is easy to now calculate the probability for $ 110 (it will yield a very small result): $$ 1 - P(R \le 0.1) = 1 - \Phi(\dfrac{0.1 - μ}{σ}) = 1 - \Phi(4) \in O(10^{-5})$$ 2. An investor is looking to calculate the beta of Apple (AAPL) as compared to the SPDR S&P 500 ETF Trust (SPY). Based on recent five-year data, the correlation between AAPL and SPY is 0.83. AAPL has a standard deviation of returns of 23.42% and SPY has a standard deviation of returns of 32.21%. What is the value of beta for AAPL in this case? Is AAPL more volatile than the overall market?

Solution

This is an easier question meant to make you familiar with these type of questions.

We know that the market has a stdev of $\sigma_{SP} = 32.21\%$ which helps us compute the denominator (variance) in the beta formula: $\sigma_{SP}^2$.

However, to get the numerator, we need the covariance between the individual stock (AAPL) and the market. That's why we have been provided the correlation coefficient: $$Correlation = \rho = \dfrac{Cov(AAPL, SP)}{\sigma_{SP} \cdot \sigma_{AAPL}}$$ Following this, we can easily calculate beta: $$beta = \dfrac{Cov(AAPL, SP)}{\sigma_{SP}^2} = \dfrac{\rho \cdot \sigma_{SP} \cdot \sigma_{AAPL}}{\sigma_{SP}^2} = \dfrac{\rho \cdot \sigma_{AAPL}}{\sigma_{SP}} = 0.83 \cdot \dfrac{0.2342}{0.3221} = 0.6035 < 1$$ As beta is much lower than 1, we conclude that AAPL is less volatile than the overall market (about $40\%$ less volatility in theory), so it would be a safer bet for investment, although the returns may also be lower as a result.

3. Suppose you have a portfolio of 100 options. Then I give you a subset of trades in which you can make. The trades consist of possible buys/sells of different options from different clients. Discuss how would you design a trading system/algorithm to determine which trades to accept and which to deny?

Solution

The question does not provide many details, it is up to you to make assumptions and try to solve such a problem.

Assuming all the options are on the same underlying (say the Dow Jones), the option portfolio will have overall stats like Delta, Gamma, Vega which can be easily computed. This is the first thing you need to bring up when devising a strategy for portfolio management.

The managers will also have targets in mind for these stats (either as optimal values $δ,γ,ν$ or perhaps acceptable confidence intervals $δ_Lδδ_H$).

A simple algorithm would accept a trade if it brings the parameters of the portfolio closer to the desired values. For example if Delta of the portfolio is already too high, then you do not accept any trades with a positive delta, but you do accept negative delta trades, which help to bring the portfolio delta down.

If the options are on different underlyings it gets more complicated, we might have to keep track of multiple Deltas with respect to multiple underlyings.

4. Why is Brownian motion useful in finance?

Solution

We can define Brownian motion as simply the limit of a scaled (discrete-time) random walk. It is very intuitive and arguably one of the simplest and best understood time-continuous stochastic processes. But why do we care about random walks? Well, it turns out that Brownian Motion can be a reasonable process to use for modelling changes in log prices. Physical objects move according to simple smooth curves that can be represented by low order polynomials: a straight line, a parabola, an ellipse, etc. Financial market prices move in a completely different way, as can be seen by looking at any graph of stock prices, interest rates etc. in a newspaper: there are constant, erratic fluctuations, sometimes in one direction, sometimes in the other, sometimes small and sometimes big, that give the curve a rough, random appearance. The Brownian Motion is a suitable model for this kind of curve.

Assuming that log-returns follow a Brownian motion (with drift), you can easily derive closed-form solutions for option prices. Brownian motion is furthermore Markovian and a martingale which represent key properties in finance.

5. I have $\$50$ and Im gambling on a series of coin flips. For each head I win $\$2$ and for each tail I lose $\$1$. Whats the probability that I will run out of money? ?

Solution

The trick here is to consider how the probabilities shift as we consider different starting amounts. Under the problem statement, the probability that you lose all the money at $n$ dollars is $\dfrac{1}{2}$ the probability that you lose all the money at $n+2$ plus $\dfrac{1}{2}$ the probability that you lose all the money at $n-1$ dollars.

Therefore, we have the recurrence formula: $$p(n+2) = 2p(n) - p(n-1)$$ This is easily solvable with basic homogeneous linear recurrences theory; we compute the roots of the associated polynomial: $$t^3 - 2t + 1 = 0 \Leftrightarrow t(t-1)(t+1) - (t-1) = 0 \Leftrightarrow (t-1)(t^2+t-1) = 0$$ We have 3 distinct roots: $$-1, \dfrac{-1+\sqrt(5)}{2}, \dfrac{-1-\sqrt(5)}{2}$$ So we have: $$p(n) = a + b \cdot (\dfrac{-1+\sqrt(5)}{2})^n + c \cdot (\dfrac{-1+\sqrt(5)}{2})^n$$ Now in order to find $a,b,c$, we usually substitute n with points for which we know the value of $p(n)$. We do know that $p(0)=1$ - this is the terminal state (it's probability 1 to lose all the money if you don't have money at all to begin with).

For other values of $n$ (e.g. 1,2..) we can't find $p(n)$; however, $$ \lim_{n\to\infty} p(n)=0$$ This is because the underlying random walk (that we can use to describe the phenomenon) has increments with positive mean, intuitively, the probability that you lose money having an infinite budget as a start tends to be close to 0.

As $(\dfrac{-1+\sqrt(5)}{2})^n = 0 $ when $n\to\infty$, we will need to have only $c=0$ and $a=0$. Finding $b$ is done by $p(0)=1$ and we have $b= 1$. The final answer is: $$p(n) = (\dfrac{-1+\sqrt(5)}{2})^n$$ 6. Let $X \sim U(0,1)$. We draw $n$ samples from this distribution: $\{x_1, x_2, x_3,...,x_n\}$. What is the expected value of $max(x_i)$?

Solution

Let us consider $max(x)$ as its own random variable, and calculate its probability distribution, $P(max(x)=k)$ for $0k1$.

We know that $$E(max(x)) = \int_{0}^{1} p(k) \cdot k \,dk $$ We need to find the PDF of $max(x)$, to do this we shall calculate the CDF and derive that result. Therefore: $$P(max(x) \le k) = P(x_i \le k, \forall i=\overline{1,n}) = \prod_{i=1}^{n} P(x_i \le k) = k^n$$ and the PDF si the derivative of that expression: $$p(max(x) = k)=n \cdot k^{n-1}$$ Having computed all of this, we are just left to plug them in: $$E(max(x)) = \int_{0}^{1} n \cdot k^{n-1} \cdot k \,dk = \dfrac{n}{n+1}$$ 7. Suppose that X and Y are mean zero, unit variance random variables. If least squares regression (without intercept) of Y against X gives a slope of β (i.e. it minimises [(Y βX)^2 ]), what is the slope of the regression of X against Y?

Solution

The question is asking for the value of $\beta$ when [(Y βX)^2 ] $\to 0$. This has a shape of a parabola with respect to $\beta$: $$ [(Y βX)^2 ] =Var(Y)2 \beta Cov(X,Y)+\beta ^ 2Var(X)$$ This function reaches its minimum (we can easily take the derivative to 0 to get this) at: $$\beta = \dfrac{Cov(X,Y)}{Var(X)}$$ 8. If I break a stick of unit length into $n \in \mathbb{N}, n\le 1$ random pieces, whats the expected length of the largest piece?

Solution

The is a known result in the literature, the interviewers probably just want to see if you know about it and if not, how it can be solved. The answer is: $$\dfrac{1}{n} H_n$$ where $H_n$ is the $n$-th Harmonic number.

The main idea behind getting this is the following: define $X_1,X_2,,X_{n1}$ denote the positions on the stick where the cuts are made, let $V_i=X_iX_{i1}$, where $X_0=0$ and $X_n=1$ - the lengths of the pieces of stick. The idea is to compute $P(V_{(n)}>x)$, where $V_(n)$ is the largest piece of stick. This has a binomial representation using the inclusion/exclusion principle. After that, we just need to compute $$E[V_{(n)}] = \int_{0}^{\infty} P(V_{(n)}>x)dx$$ 9. Consider all 100 digit numbers, i.e. those between $0$ to $10^{100}$ 1, inclusive. For each number, take the product of non-zero digits (treat the product of digits of 0 as 1), and sum across all the numbers. Whats the last digit?

Solution

You can in fact calculate the full sum of this expression. The question is worded in such a way that you might think it is more difficult than in reality.

The main idea is induction. Let's say we want to calculate this sum for 1-digit numbers only. This sum would be $$S(1) = 1+1+2+3+4+5+6+7+8+9=1+45=46$$ (with the convention that the product between 0 and 1 is 1).

Now if we have 2-digit numbers, we have 1 more open slot, so we can group the sums having a common factor (the first position):

S(2) = S(1) [for when we have 0 at the first position] + S(1) [for when we have 1 at first position] + 2 S(1) [for when we have 2 at first position] + ... + 9 S(1) [for when we have 1 at first position]

So, $S(2) = 46 S(1)$. By induction, we can prove that: $$S(n+1) = 46 S(n)$$ Thus, $$S(n) = 46^n$$ and 6 yields only 6 as last digit when multiplied together, so the answer is $6$.

10. I have two children. One is a boy born on a Tuesday. What is the probability I have two boys?

Solution

The question is vague on purpose. We need to define a mathematical/probabilistic model of the problem statement for this to work.

Let (x,y) a pair of children. Let's say that a child is an ordered pair (gender $\times$ birthday) and define the predicate $H(x)$ on a child as x.gender = boy AND x.birthday = tuesday.

We need to calculate the probability:

P(x is a boy and y is a boy | H(x) or H(y))

Note that the problem statement does not say that the first born is a boy, that's why we have an OR statement as condition.

Using basic probability formulas:

$$P(x \text{is a boy and y is a boy} |H(x) or H(y)) = \dfrac{P(x \text{is a boy and y is a boy and} (H(x) or H(y)))}{P(H(x) or H(y))}$$ $$ = \dfrac{P((x \text{is a boy and y is a boy and H(x)}) or (x \text{is a boy and y is a boy and H(y)}))}{P(H(x) or H(y))}$$ $H(x)$ and $H(y)$ are not mutually exclusive, so: $$P(H(x) or H(y)) = P(H(x))+P(H(y)) - P(H(x))P(H(y))$$ Therefore: $$P(H(x) or H(y)) = \dfrac{1}{2} \cdot \dfrac{1}{7} + \dfrac{1}{2} \cdot \dfrac{1}{7} - \dfrac{1}{2} \cdot \dfrac{1}{2} \cdot \dfrac{1}{7} \cdot \dfrac{1}{7}$$ We can apply the same thing for the numerator: $$P((x \text{is a boy and y is a boy and H(x)}) or (x \text{is a boy and y is a boy and H(y)}))=$$ $$ P(x \text{is a boy and y is a boy and x born on Tuesday}) +$$ $$ P(x \text{is a boy and y is a boy and y born on Tuesday}) - $$ $$ P(x \text{is a boy and y is a boy and x born on Tuesday and y born on Tuesday}) $$ which is: $$ \dfrac{1}{2} \cdot \dfrac{1}{2} \cdot \dfrac{1}{7} + \dfrac{1}{2} \cdot \dfrac{1}{2} \cdot \dfrac{1}{7} \dfrac{1}{2} \cdot \dfrac{1}{2} \cdot \dfrac{1}{7} \cdot \dfrac{1}{7}$$ Computing all these numerical values we reach the answer: $$\dfrac{13}{27}$$ 11. How many ways are there to tile dominos (with size 2x1) on a grid of 2xn?

Solution

Let $f(n)$ be the number of ways to tile a $2$ by $n$ grid with dominoes. We can compute: $f(1)=1$ and $f(2)=2$.

Consider the first square in the grid (the leftmost square in the first row)

A) you could place a domino vertically on that, so there are $f(n-1)$ ways to tile the rest of the grid.

B) or you could place the domino horizontally on it, so you must place another domino horizontally below that (because otherwise the grid won't be filled) and there are $f(n-2)$ ways to tile the rest of the grid.

So we have: $$f(n)=f(n-1)+f(n-2)$$ which is Fibonacci sequence with different starting points.

12. [Game Theory] A company has a competition to win a car. Each contestant needs to pick a positive integer. If theres at least one unique choice, the person who made the smallest unique choice wins the car. If there are no unique choices, the company keeps the car and theres no repeat of the competition. It turns out that there are only three contestants, and youre one of them. Everyone knows before picking their numbers that there are only three contestants. How should you make your choice?

Solution

The interviewers want you to discuss if there is a dominant strategy that definitely win the game for one player or if the game can be solved through a Nash Equilibrium. At first sight, it might be difficult to find a dominant strategy; choosing always $1$ can be easily countered yielding $0$ as reward, we don't want that. Can we find a Nash Equilibrium?

Consider mixed strategies $S$ where you choose positive integer $i$ with probability $S_i$. We can think of S as a standard simplex over all the natural numbers - so the sum of all probabilities will be $1$.

Let's try to find if there is a Nash Equilibrium when the other players have the same probability distribution over integer choices. This is the easiest we can go about this. $S_i$ for $i$ an integer are still variables for now but they do not differ from player to player.

It's usually a good thing to assume a certain type distribution and if the interviewers agree, we can restrict our search to the geometric distributions with some parameter $p$: $$ S_i=(1-p)p^{i-1} $$ Under these assumptions, the probability that you win choosing the number $k$ is the probability that the two opponents choosing the same number $j < k$ plus the probability that they both choose a number $j > k$.

These events are mutually exclusive so the probability to win choosing $k$ is: $$W(k) = \sum_{i=1}^{k-1} S_i \cdot S_i + (1-\sum_{i=1}^{k} S_i) \cdot (1-\sum_{i=1}^{k} S_i) = $$ $$ \dfrac{1-p}{1+p} + \dfrac{p^{2k-2}}{1+p} \cdot (p^3+p^2+p-1) $$ In order for $S$ with all $S_i>0$ to be a Nash Equilibrium, no player can have an incentive to "defect", so no $W_k$ can be greater than the probability $W_SS$ of winning if you also choose mixed strategy S.

The total probability that you win having the strategy $S$ is the weighted sum of the probability that you pick an integer $i$ and the probability of winning when picking the integer $i$: $$\sum_{i=1}^{\infty} W_i \cdot S_i$$ However, $W_i \le max_{k} W_k, \forall i$, so $$\sum_{i=1}^{\infty} W_i \cdot S_i \le max_{k} W_k (\sum_{i=1}^{\infty} S_i) = max_{k} W_k$$ So in order for this to be a Nash Equilibrium we must not allow a distinct maximum value of $W_k$ to exist, therefore all $W_k$ should be equal to each other.

We conclude that $p$ must be a real root of the equation: $$x^3+x^2+x-1=0$$ Thankfully, this has only a real root: $x \sim 0.5436$, so we can define our probability simplex that denotes the mixed strategy for each contestant: $$ (S_1,S_2,S_3, S_4, S_5, S_6, S_7, ...) = (.45, .24, .13, .07, .03, .02, .01, ...) $$ This way, we can achieve a Nash Equilibrium. Note that the first integers naturally have a higher chance of getting picked, which is to be expected.

Image placeholder

Tidor Pricope

Working as a quant developer seems to be cool!

Leave a comment