DeskPrep
PYTHONintermediate~60 min

VaR Backtest Starter

Implement a historical VaR estimate and backtest exceptions against realised PnL.

The scenario

You've joined the risk team. The desk runs a 99% one-day Value-at-Risk number every evening, and the regulator — and your boss — want to know it's honest. You're handed a history of daily portfolio returns and asked to estimate a rolling historical VaR and backtest it: how often did the actual loss blow through the VaR, and is that the right number of times?

Where this shows up

Estimating and backtesting VaR is a core market-risk and quant-research task at firms of this type.

bank market-risk desksquant research & risk teams at funds

Firms such as Citadel, JPMorgan.

DeskPrep is not affiliated with, endorsed by, or sponsored by any named firm. Firm names are used for illustrative, educational purposes only and do not imply that these materials are official assessments of, or are connected with, those firms.

Task brief

README.md
# VaR Backtest Starter

**Role relevance:** Quant research take-home
**Estimated time:** 60 minutes
**Difficulty:** Intermediate
**Format:** Python (.py)

## What you are given
- returns.csv of daily portfolio returns
- var_backtest_starter.py with TODOs

## What you must deliver
1. Compute 99% 1-day historical VaR on a rolling window
2. Flag days where the loss exceeds VaR
3. Report the exception rate and a Kupiec test verdict

## Constraints & assumptions
Use a 250-day window. Do not use a parametric/normal VaR.

## Submission note
Complete the starter file, then compare your work against the mark scheme.

Your tasks

  1. 01Compute a rolling one-day 99% historical VaR (as a positive loss) over a trailing window.
  2. 02Flag exceptions where the realised loss exceeds the VaR known the day before (no lookahead).
  3. 03Report the exception count and rate against the expected 1%.
  4. 04Grade the model with the Kupiec proportion-of-failures test.

How you're assessed

Rolling historical VaR3 pts
Lookahead-free exceptions3 pts
Exception rate & reporting2 pts
Kupiec POF interpretation1 pt
Clean, vectorised code1 pt
Total10 pts

The full points-based mark scheme is included with the pack.

What you'll learn

  • What a VaR number does and doesn't promise, and how it's estimated from history.
  • Why a backtest must use only information known before the day it judges.
  • How the Kupiec test decides whether the breach count is acceptable — and why clustering still matters.

Study alongside