Quantitative Risk Management in Python
Jamsheed Shorish
Computational Economist











from scipy.stats import gaussian_kdekde = guassian_kde(losses)loss_range = np.linspace(np.min(losses), np.max(losses), 1000)plt.plot(loss_range, kde.pdf(loss_range))

gaussian_kde .resample() methodgaussian_kde has no .expect() method => compute integral manually    .expect() method written for exercisesample = kde.resample(size = 1000)VaR_99 = np.quantile(sample, 0.99)print("VaR_99 from KDE: ", VaR_99)
VaR_99 from KDE: 0.08796423698448601
  Quantitative Risk Management in Python