Quant Ladder

Linear Algebra for Quant Work

3 min read

Quant finance is applied linear algebra with money attached. A portfolio is a vector; a risk model is a matrix; "what are my biggest risks" is an eigenvalue question. This lesson rebuilds the essentials in those terms.

Vectors and dot products: portfolios and P&L

A portfolio is a weight vector w=(w1,,wn)w = (w_1, \ldots, w_n); asset returns over a day form another vector rr. The portfolio's return is the dot product:

Rp=wr=iwiriR_p = w^\top r = \sum_i w_i r_i

Dot products measure alignment: wr=wrcosθw^\top r = \|w\|\|r\|\cos\theta. Two return streams with high positive dot product (after demeaning) are correlated strategies — geometrically, vectors pointing the same way. "Diversification" means choosing vectors that are close to orthogonal.

Matrices: the covariance matrix is the risk model

The object at the center of everything is the covariance matrix Σ\Sigma, with Σij=Cov(ri,rj)\Sigma_{ij} = \operatorname{Cov}(r_i, r_j). Portfolio variance is the quadratic form

Var(Rp)=wΣw,\operatorname{Var}(R_p) = w^\top \Sigma\, w,

which is the two-asset formula (w12σ12+w22σ22+2w1w2σ12w_1^2\sigma_1^2 + w_2^2\sigma_2^2 + 2w_1w_2\sigma_{12}) written once for any nn. Facts interviews expect:

  • Σ\Sigma is symmetric and positive semi-definite (PSD): wΣw0w^\top \Sigma w \ge 0 always — variance can't be negative. If your estimated Σ\Sigma isn't PSD, it implies a portfolio with negative variance: a data or estimation bug, and a classic "spot the problem" interview prompt.
  • Correlations near ±1 make Σ\Sigma nearly singular — some portfolio has almost zero risk, which optimizers will lever into absurd positions. Near-singularity is why raw sample covariance matrices are never used untreated.

Eigenvalues: what the market's principal risks are

Since Σ\Sigma is symmetric, it diagonalizes: Σ=QΛQ\Sigma = Q \Lambda Q^\top with orthonormal eigenvectors qiq_i and eigenvalues λ1λ20\lambda_1 \ge \lambda_2 \ge \cdots \ge 0. Interpretation:

  • Each eigenvector is a portfolio (a linear combination of assets); its eigenvalue is that portfolio's variance.
  • The top eigenvector of an equity covariance matrix is, empirically, "everything moves together" — the market factor. The next few look like industries or styles. This is PCA, and it's the mathematical skeleton of factor models: a handful of large eigenvalues carry most of the variance, and the rest is diversifiable noise.
  • The trace (λi\sum \lambda_i = total variance) and the share λ1/λi\lambda_1 / \sum \lambda_i ("how much of the market is one big trade?") are quoted on real desks — that share spikes in crises, when correlations converge and diversification dies.

Solving systems: regression in matrix form

OLS with design matrix XX and target yy solves the normal equations:

β^=(XX)1Xy\hat\beta = (X^\top X)^{-1} X^\top y

Two practical readings. First, (XX)(X^\top X) is (up to scaling) the covariance matrix of the predictors — if predictors are collinear it's near-singular, β^\hat\beta explodes, and you've rediscovered why multicollinearity destabilizes regressions. Second, nobody inverts matrices in practice; libraries solve the system via decompositions (QR, Cholesky) for speed and numerical stability — a fact worth mentioning in any "how would you implement this" follow-up.

The interview versions

  • "Why must a covariance matrix be PSD? What would a negative eigenvalue mean?" — A portfolio with negative variance; impossible, so the estimate is broken (usually asynchronous data or more assets than observations).
  • "You run PCA on 500 stocks. What does the first component look like, and what fraction of variance might it explain?" — Roughly equal positive weights (the market), often 30–50% in stressed periods.
  • "XXX^\top X is nearly singular — what happens to your regression, and what do you do?" — Coefficients become huge and unstable with opposite signs; fix with regularization (ridge adds λI\lambda I, making the matrix invertible — a one-line answer that bridges directly into the machine-learning course).