`A selection of topics on IT and its application to finance. `

Send me your comments, questions or suggestions by clicking **here**

`elmama`

Date | Asset1 price | Asset2 price | ... | AssetN Price |

11-Jan-2010 | 123.456 | 99.99 | ... | 23.45 |

12-Jan-2010 | 100.07 | 100.00 | ... | 20.99 |

13-Jan-2010 | 98 | 91 | ... | 19.87 |

etc ... |

Any time we are dealing with portfolios that contain more than 2 assets that we want to perform calculations on such as evaluating risk, returns and so on it is better to construct a Variance-Covariance matrix. Let’s assume our portfolio P consists of N assets and we have k periods worth of return data for each of the assets. To generate a variance-covariance matrix we do the following steps:

For each of our N assets we obtain a time-series of historical price data, starting with the earliest first. We aim to get as long a series as possible.

1) Portfolio P

2) For each of the assets calculate the continuously compounded returns for each of the kth periods as

LN(Asset1 Value (k+1)/Asset Value1 (k) etc …..

3) For each of the assets calculate the average of the values obtained from step (2).

This will result in an N x1 Matrix , let's call it **R**

4) For each of the assets for each of the kth periods calculate the excess return over the average value calculated in step (3). This will result in an N x k matrix, let’s call it X

The variance covariance matrix lets say **∑** is given by**∑ = 1/k * X’ X**

i.e the transpose of the matrix of excess returns X’ multiplied by matrix of excess returns X divided by the number of periods. This will result in an N x N variance covariance matrix **∑**.

So now we have **∑** we can use it to calculate some useful portfolio values.

e.g The portfolio volatility **σ = √X’∑X**

And now that we have

a) the portfolio volatility **σ**,

b) the average of each of the asset returns **R**

( the1xN matrix calculated in step 3 earlier )

c) and if we assume we have an Nx1 matrix of the asset weights, say **W**, in the portfolio we can calculate the expected return **E(r)** of the portfolio using:-

E(r) = W’R = {W1, W2,… WN} {R(1)}

{R(2)}

{…....}

{R(N)}

If we happen to know or make an assumption about the risk-free rate **rf** we can also compute the **Sharpe ratio** as

**Sr** = (**E(r) – rf**)/**σ**

Finally we can also compute the Value At Risk VaR as for example 99% **VaR**

VaR = NORMINV(99%,E(r),σ)