The Analyst's Path

Stress testing vs scenario analysis

Stress testing asks what one specific, named shock would do to a portfolio, with no probability attached. Scenario analysis runs several named shocks side by side, so a risk desk sees which ones hurt and which barely register. Both work out the portfolio impact as a weighted sum of position weights and shocked returns. Because neither attaches a probability, a shock doesn't have to be likely to be worth knowing about.

3 min readPart of Risk Systems in Code: VaR, ES, Stress & ScenarioOpen in course mode

Advertisement

VaR and ES are fundamentally probabilistic statements, they describe the ordinary range of outcomes a statistical model assigns real likelihood to, at some stated confidence level. Stress testing asks a structurally different question, and asks it on purpose without attaching any probability at all: if this specific, named, historically-plausible shock happened tomorrow, what would it do to the book? A shock does not need to be likely to be worth knowing about, a 2008-style liquidity freeze, a sudden 15% single-day equity decline, a currency devaluation, and the entire value of the exercise comes from not filtering these scenarios through "but how probable is that, really," which is exactly the question a VaR model would ask and exactly the question a stress test is designed to bypass.

How is a stress test calculated?

Mechanically, code pack exercise QD2.02-e07 is deliberately simple, because the value here is in the discipline of running it consistently, not in mathematical sophistication: given a book's weights ({ticker: weight}, summing to 1.0, a stress test on a book that does not actually sum to 100% is measuring the wrong thing entirely, and the exercise validates this explicitly) and a named scenario's shocked returns ({ticker: shocked_return}), the portfolio-level impact is the weighted sum sum(weight[t] * shock.get(t, 0.0) for t in weights), a ticker the scenario doesn't mention is simply assumed unshocked. Applied to a five-name mixed India/US book (NILAM, BRPEAK, TARANG, CRSTNE, PIPPAL, the same illustrative roster this module's bundled synthetic-portfolio dataset uses) under a shock hitting four of the five names, the portfolio loses 13.95%; under a broad rally scenario touching all five, it gains 4.10%. Neither number carries a probability attached, and that is not a gap to fill, it is the entire design.

Advertisement

Scenario analysis: comparing several named futures side by side

Scenario analysis is stress testing run several times over, with several different named stories compared side by side rather than one story examined in isolation (a rate shock, an equity crash, a sector rotation, a currency devaluation) so a risk desk sees not just a single worst case but the shape of the book's vulnerability: which stories genuinely hurt, and which barely register. Code pack exercise QD2.02-e08 runs a whole dict of named scenarios through the identical weighted-sum logic as the single-scenario stress test, then reports the full table and identifies the worst scenario by name.

The one property worth internalising here, because it is a genuinely common intuition trap and the exercise's hidden tests are built specifically to catch a solution that falls into it: the worst scenario is not necessarily the one containing the single largest individual shock number. A scenario with one dramatic −60% shock on a position that is only 10% of the book can lose less, in total, than a scenario applying a much milder −15% to −20% shock spread across the entire book, total portfolio impact is a weighted sum across everything held, not the size of the loudest number in the table. Skimming a scenario table for its scariest-looking single entry, instead of actually computing the weighted portfolio impact of every row, is exactly the kind of shortcut that produces a confidently wrong "worst case."

Advertisement

Part of the course

This page is part of Risk Systems in Code: VaR, ES, Stress & Scenario (QD2.02), in Phase 12: Finance Plus, AI and the quant-code track. The module's flashcards and its quiz are in the app.