VaR based on sorted historical returns

We know that stock returns do not necessarily follow a normal distribution. An alternative is to use sorted returns to evaluate a VaR. This method is called VaR based on historical returns. Assume that we have a daily return vector called ret. We sort it from the smallest to the highest. Let's call the sorted return vector sorted_ret. For a given confidence level, the one-period VaR is given here:

VaR based on sorted historical returns

Here, position is our wealth (value of our portfolio), confidence is the confidence level and n is the number of returns. The len() function shows the number of observations and the int() function takes the integer ...

Get Python for Finance - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.