On Wed, 20 Oct 2010 02:41:43 -0700 (PDT), Amy Milano

<

[hidden email]>

wrote:

> Dear all,

>

> I am having following conceptual problem when I am trying to find out

> Value at Risk (VaR) for the portfolio. I am just giving an indicative

> portfolio.

>

> (a) stocks (equity) of 3 different companies say e.g.

>

> E1 500 equity shares

> E2 1000 equity shares

> E3 100 equity shares

>

> I have closing prices for last 1 year (i.e. say 250 days) and thus I

> obtain 250 portfolio values by multiplying the respective number of

equity

> shares by respective closing prices and add them.

>

> Thus, I have 250 portfolio values. I obtain 249 portfolio returns using

> "LN".

>

> Problem (A)

>

> My problem is is my method of calculating returns correct?

No.

Don't worry about weights yet. Get the returns for each individual series

before sorting out your portfolio weights. You have all the information,

so you should use it.

The function 'Return.calculate' from 'PerformanceAnalytics' will do what

you want, but the calculation isn't hard. If 'pr' is your variable of

prices,

pr/Lag(pr, k = 1) - 1

will give you simple returns (which I typically recommend using with daily

series), or

diff(log(pr))

will give you compound returns. I typically want a simple return series

for each asset, and will turn it into a compound series later, only if

required, to look at total portfolio return. Sticking with simple returns

avoids adding compounding estimation errors into your calculations later

on.

You want to calculate returns on each price series without worrying about

your invested amount. It makes everything else simpler.

> In the sense, should I calculate returns for all these 3 companies

> separately (unlike calculating the portfolio value by adding the values

of

> these 3 companies together) and then carry out the further analysis like

> calculating the correlation matrix etc.

There's a function for VaR too that is likely more sophisticated than

anything you would do by hand...

Typically, if you have all the information, why wouldn't you use it?

If you have a simple or compound return series for all the instruments in

your portfolio, then you can readily calculate the portfolio return,

portfolio risk, and contributions to risk. All you need are weights. Take

the capital required to establish each of your positions, add it all up.

this is 100% of your capital. Now, the capital for opening each position

divided by the total capital is the percent weight you've invested in each

position.

The function 'Return.portfolio' will take your per-instrument returns, and

calculate your portfolio return (assuming no rebalancing, though there's a

function for that too). It can also calulate you 'contribution' to total

return from each of the assets.

> Problem (B)

>

> If I were to consider returns separately for the above three companies,

> what will happen if there are say 5000 companies (equity only) in my

> portfolio? How do I handle these many companies?

See above. These functions are routinely used on very large portfolios.

> Problem (C)

>

> How do I proceed if besides having equity, I also have debt and forex

> transactions also. (Please note that I am asking these questions

> (especially Problem (C) form calculating returns point of view as say

for

> Forex transactions, I consider the spot exchange rates and the LIBOR

rates

> (depending on the currency and the maturity period) as risk factors and

> calculate the Mark to Market (MTMs) values.

If you have a series of MTM 'prices' use these in step A above.

> So my problem basically is how do I arrive at returns in a portfolio.

>

> I apologize if I have not put up the problem in correct and short words.

> Please forgive and guide me,

Hopefully this helps.

You should find most of the other functions you need for univariate and

portfolio risk (SharpeRation, VaR, ES, etc.) in PerformanceAnalytics as

well.

Regards,

- Brian

--

Brian G. Peterson

http://braverock.com/brian/Ph: 773-459-4973

IM: bgpbraverock

_______________________________________________

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/r-sig-finance-- Subscriber-posting only. If you want to post, subscribe first.

-- Also note that this is not the r-help list where general R questions should go.