# Monte Carlo model with multiple assets step by step

Here are the following steps to calculate Monte Carlo VaR. I am learning how to proceed with each steps and I would need somebody who can explain. Do I have to create only 1 vector in step 4 (even if i have multi asset portfolio) ? In which case I don't understand which mu and sigma i use to created my standard normal variates since I want to mimic estimators from my assets log returns.

Here are the steps I have managed to pickup using different sources:

1. Estimate the portfolio's current value $$P_0$$.

2. Build the portfolio's covariance matrix using stock historical data.

3. Create the Cholesky decomposition of the covariance matrix.

4. Generate a vector of n independent standard normal variates

5. multiply the matrix resulting from the Cholesky decomposition with the vector of standard normal variates in order to get a vector of correlated variates.

6. Calculate the assets' terminal prices using geometric brownian motion. $$S_i(T) = S_i(0) \cdot e^{((\mu-\frac{\sigma^2}{2})T + \sigma \sqrt{T} \epsilon_i})$$, where $$\epsilon_i$$ corresponds to the correlated random variate for asset $$i$$ obtained from the vector of correlated variates.

7. reevaluate the portfolio's value at time $$T$$, $$P_T$$, using the stock prices generated in the previous step.

8. Calculate the portfolio return using $$R_T=\frac{P_T−P_0}{P_0}$$

9. Repeat steps 4-8 many times (for example $$n=10,000$$ simulations).

10. Sort the returns in ascending order.

Here's an example correlating 3 random normal variables that you can apply to your monte carlo:

Let:

$$\bf Y \sim \mathcal N(0, \Sigma)$$

where $\textbf{Y} = (Y_1,\dots,Y_n)$ is the vector of normal random variables, and $\Sigma$ the given covariance matrix.

The process is:

1. Simulate a vector of uncorrelated Gaussian random variables, $\bf Z$
2. Then find a square root of $\Sigma$, i.e. a matrix $\bf C$ such that $\bf C \bf C^\intercal = \Sigma$.

Then the target vector is given by $$\bf Y = \bf C \bf Z.$$

Here is a dummy matlab code:

N = 500000
u_1 = normrnd(zeros(N,1),1);
u_2 = normrnd(zeros(N,1),1);
u_3 = normrnd(zeros(N,1),1);
u_4 = normrnd(zeros(N,1),1);

rv = [u_1 '; u_2'; u_3'; u_4'];

VarCov = [Some positive semi-definite matrix here 4x4];

ch = chol(VarCov);
result = ch * rv;