Portfolio VaR Calculator
Compute parametric and historical VaR for a multi-position book, decompose it into component VaR and quantify the diversification benefit.
The scenario
You've joined the market-risk team. Every evening the book's Value-at-Risk is produced and decomposed. Build the calculator: parametric and historical VaR for a multi-position portfolio, the diversification benefit versus the standalone VaRs, and each position's component VaR so the desk can see what drives the number.
Where this shows up
Computing and decomposing portfolio VaR is a core market-risk task and a common risk take-home at firms of this type.
Firms such as Barclays, JPMorgan, Man Group.
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
# Portfolio VaR Calculator **Role relevance:** Market Risk take-home **Estimated time:** 60 minutes **Difficulty:** Intermediate **Format:** Python (.py) ## What you are given - portfolio_var_starter.py with the function signatures stubbed and a self-check harness - positions.csv - 4 positions and their market values (11m book) - returns.csv - 500 business days of daily returns per asset ## What you must deliver 1. Parametric VaR of the book from the covariance matrix 2. Historical VaR from the realised PnL distribution, and a comparison 3. The diversification benefit versus the standalone position VaRs 4. Component VaR per position, summing to the portfolio total ## Constraints & assumptions 99% confidence, 1-day horizon. Use the sample covariance (ddof=1) of the supplied returns. VaR is reported as a positive loss in GBP. pandas and numpy only. ## Submission note Complete the starter file, then compare your work against the mark scheme.
Your tasks
- 01Compute the parametric VaR of the portfolio from the position weights and the covariance matrix of returns.
- 02Compute the historical VaR from the portfolio's realised PnL distribution and compare the two.
- 03Quantify the diversification benefit: the sum of standalone position VaRs minus the portfolio VaR.
- 04Compute each position's component VaR (contributions summing to the total) and identify the largest contributor.
How you're assessed
The full points-based mark scheme is included with the pack.
What you'll learn
- How parametric and historical VaR differ and when each is trusted.
- Why VaR is subadditive here, and how diversification shows up in the number.
- How component VaR attributes the total to positions so risk can be managed.