[R-sig-finance] [R] [R-pkgs] New package 'portfolio'

Jeff Enos jeff at kanecap.com
Fri Mar 10 16:29:18 CET 2006


 > 1) I see that summary(p) shows you the first few names in a portfolio.  Is
 > there a way to see all the holdings (say all 50)?

The number of stocks to display in summary() hasn't yet been
parameterized, so the easiest way for now is to work with the data
frames in the 'weights' and 'shares' (for objects of class
'portfolio') slots.

 > 2) Is there a way to creat a long only portfolio.  If I have a dataframe of
 > 20 stocks and tell it to make a portfolio of size 20, it tells me there are
 > not enough stocks becaue it wants to go long 20 and short 20.  I only want
 > long portfolios.

Setting the 'sides' slot to c("long") will allow you to create a
long-only portfolio.  There's an example of a simple long-only
portfolio in class?portfolioBasic and in the beginning of

 > 3) Also, how best to cap weight the portfolio?

Right now the user must supply all required data to the 'data' slot of
portfolioBasic objects.  So, if you wanted to create a cap-weighted
portfolio you'd need to have a measure of cap already in your data

A portfolio created with type = "relative" will interpret the column
of the 'data' slot specified by the 'in.var' slot as position

Here's a simple example using one of the package's data sets:

p <- new("portfolioBasic",
         size   = "all",
         type   = "relative",
         id.var = "symbol",
         in.var = "cap.bil",
         data   = dow.jan.2005)

 > 4) Can you give me an example of how to view/modify the code?

Let's discuss this off-list.


More information about the R-sig-finance mailing list