Calculating risk metrics
Value at risk and conditional value at risk
Value at risk and conditional value at risk are measurements of potential losses over time. These metrics can be used to characterize the risk inherent in a given asset or portfolio.
Value at risk
RiskAMP provides a function SimulationVaR
for calculating value at risk. It returns the potential loss for an asset or portfolio over time, based on results observed during a simulation.
In essence, the VaR calculation calcultes the gain or loss in each trial of a simulation. Then it sorts these by value, and returns the value observed at a given confidence level (typically 95% or 99%).
If the 95% VaR for a portfolio is $1M, this can be interpreted as saying “in the worst 5% of cases, the portfolio will lose $1M or more”.
VaR is typically calculated over a given time period, such as one day or one year. You can use the SimulationVaR function at different points in your model to show potential risk at different periods.
The SimulationVaR function takes three parameters:
- Starting value
A reference to the starting value of the asset or portfolio. Typically this value is constant, if you are measuring from day 0 or today, but in some cases the value might change.
- Ending value
A reference to the value of the asset or portfolio at the end of the period you are measuring.
- Confidence level
Confidence level refers to the loss probability. Typical confidence levels for VaR are 95% and 99%, which reflect the worst 5% and 1% of outcomes respectively.
Example: Value at risk
In this example, we are calculating the 1-period and 5-period VaR for a simple portfolio.
Conditional value at risk
Conditional value at risk (CVaR), also commonly called expected shortfall, is another measure of risk over time. The calculation is similar to VaR but instead of returning the value at a certain confidence level, it returns the mean (average) of all losses that fall beyond the confidence threshold.
RiskAMP includes a function SimulationCVaR
for calculating conditional value at risk. The parameters are the same as the SimulationVaR function described above.
Example: Conditional value at risk
This example adds the 1- and 5-period conditional value at risk calculation. As expected the CVaR projected losses are larger than the VaR values because the calculation averages all observed losses beyond the 95% threshold.
For more on these metrics, see wikipedia:
https://en.wikipedia.org/wiki/Value_at_risk https://en.wikipedia.org/wiki/Expected_shortfall