Parametric var and cvar

Simple code to produce parmetric var and cvar.

On line 38 and 39 of code if i use 252 instead of 1.



port_return_optimized = np.sum(expected_maret_returns* weights)252

port_std_dev_optimized = np.sqrt(np.dot(weights.T, np.dot(stocks_cov_matrix,weights)))
np.sqrt(252)



The var and cvar values go to a negative. But Im sure this is correct. Can you tell me if anything is wrong in my code? 



 

Hello,



You can check the code for the calculation of the var and cvar values. Since it is a library you are using to calculate the values, there might be certain assumptions taken which are leading to negative values. Also, you can research and check if you have to use normal distribution (scipy.stats.norm)  which might not be appropriate, or use the historical simulation method as provided in the 'PyPortfolioOpt' library. 



There could be a few other reasons why you are getting negative values

  • The method used to calculate VaR and CVaR might not be suitable for the underlying distribution of returns. For instance, if the returns distribution is highly skewed or has heavy tails, the normal distribution assumption (used in some methods) may not be appropriate.
  • If the optimization process leads to extremely aggressive allocations, it can result in negative VaR and CVaR values.
  • If there are missing or incorrect data points in the historical return series, it can lead to unexpected results in VaR and CVaR calculations.