Rs
Module 12VaR & ESLesson 4 of 724 min

Historical VaR

Empirical quantile of PnL.

Steps

  1. Collect PnL history
  1. Sort ascending
  1. VaR_α = -quantile_α (positive loss convention)

Caveats

Needs enough history; regime changes; no guarantee for tomorrow.

Challenge

Try alpha=0.1 and interpret.

Tips
  • partial_cmp for f64 sort
  • Sign convention: positive loss
  • Need many days for 99%

Try it live

Historical VaRRust 2021
Loading editor…
Output
Press Run to compile and execute.