Learn R Programming

portfolio (version 0.2-2)

portfolioHistory-class: Class "portfolioHistory"

Description

Perform exposure, performance, and contribution analysis on all of the portfolioBasic objects that have been added to this object with the add method.

Arguments

Objects from the Class

Objects can be created by calls of the form new("portfolioHistory", ...).

Examples

Run this code
data(global.2004)

portfolios <- lapply(split(global.2004, global.2004$date),
                     function(x){
                       new("portfolioBasic",
                           name    = "test",
                           date    = as.Date(unique(x$date)),
                           id.var  = "symbol",
                           in.var  = "cap.bil",
                           ret.var = "ret.0.1.m",
                           type    = "sigmoid",
                           size    = "quintile",
                           sides   = c("long", "short"),
                           data    = x)

                     })

h    <- new("portfolioHistory",
            freq        = 12,
            exp.var     = c("currency", "sector", "liq.w", "cap.bil"),
            contrib.var = c("currency", "sector", "liq.w"))


for(i in 1:length(portfolios)) h <- add(h, portfolios[[i]])

exposure(h)
performance(h)
contribution(h)

Run the code above in your browser using DataLab