"""Calculate an interpolated return quantile.

VaR is expressed here as loss; it is not maximum loss. Sparse tail samples are unstable.
All inputs are synthetic teaching examples. Run: python 31_historical-var.py
"""
from tv_math import *

v=historical_risk([-.05,-.03,0,.02,.04],.75)
assert abs(v['var_loss']-.03)<1e-12
print(v)
