# Calculate the historical simulation VaR of the portfolio using Python

Assume that we have 200 stocks in WeiBo (WB), 300 stocks in Netflix (NFLX), 250 stocks in Ford Motor Company (F) and 150 in Royal Dutch Shell (RDS-A) as of 31 August 2019 in the portfolio.

I have computed the individual VaR of each stock which amounts to:

1) WB: 736.6841286587987

2) NFLX: 6481.021865242725

3) F: 114.6225730582521

4) RDS-A: 114.6225730582521

However, how do I use python to find the VaR of the portfolio given the individual VaRs?

• Do you have portfolio returns that you can calculate portfolio VaR from? If so, I can give you an answer with respect to using python. – amdopt Sep 9 '19 at 16:53

Let us start from the definition of the $$VAR_{\alpha}$$ at level $$\alpha$$. We denote by $$R_P$$ the random variable representing the absolute return of the portfolio (difference in value of $$P$$ between two dates). We have by definition:

$$P(R_p \leq Var_{\alpha}) = \alpha$$

As $$R_p = P_1 - P_0 = 200(P_1^W - P_0^W) + 300(P_1^N - P_0^N) + 250(P_1^F - P_0^F) + 150 (P_1^R - P_0^R)$$, we get:

$$P(200(P_1^W - P_0^W) + ... + 150 (P_1^R - P_0^R) \leq Var_{\alpha}) = \alpha$$

And you can see that you cannot extrapolate from the VAR of each stock the VAR of your portfolio. If you have some notions in probability, it is similar to say that, in general, you cannot from marginal distributions (the distribution of each stock) deduct the global distribution (the distribution of the market).

If you want to overcome this problem, you can either take the returns of your portfolio and calculate directly the historical VAR without using the VAR of each stock or you can make very strong assumptions (such as normality and independence between the stocks).

Hope I have helped. Have a good day!