Module 11 · Financial Risk and Performance Statistics Lesson 106 of 120

Expected Shortfall Intuition

Averaging the source-defined exceedance slice and auditing its probability mass.

2:43 clip5:40:51–5:43:35 in the full courseWatch on YouTube

Transcript

18 sentences · select one to jump there

Check your understanding

Why does the selected slice contain 40% here rather than 30%?

Choose one answer

Code lab

Run it yourself

The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.

106-expected-shortfall-intuition.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 106 of 120
 * Expected Shortfall Intuition
 * Module 11: Financial Risk and Performance Statistics
 *
 * Scenario: Averaging the source-defined exceedance slice and auditing its probability mass
 * Rule:     source estimator: mean{Lᵢ : Lᵢ≥type7 VaRα}
 *
 * Try it:   Why does the selected slice contain 40% here rather than 30%?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/financial-risk-and-performance-statistics/expected-shortfall-intuition/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson106() {
  const losses=[-.03,-.015,-.01,.01,.02].sort((a,b)=>a-b),alpha=.7;
  const h=(losses.length-1)*alpha,i=Math.floor(h);
  const threshold=losses[i]+(h-i)*(losses[i+1]-losses[i]);
  const selected=losses.filter(x=>x>=threshold);
  const result={threshold,selected,tailMean:selected.reduce((s,x)=>s+x,0)/selected.length};
  return result;
}

export const checkedResult = {"threshold":0.005999999999999997,"selected":[0.01,0.02],"tailMean":0.015};

// Run this file directly: npx tsx lessons/11-financial-risk-and-performance-statistics/106-expected-shortfall-intuition.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson106(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "threshold": 0.005999999999999997,
  "selected": [
    0.01,
    0.02
  ],
  "tailMean": 0.015
}

Prefer your own machine? Every file is in the course repository · open it in Codespaces.

Lesson notes

The rule

source estimator: mean{Lᵢ : Lᵢ≥type7 VaRα}