Learn R Programming

portfolio (version 0.5-3)

portfolio-class: Class "portfolio"

Description

Class "portfolio" extends class "portfolioBasic" to include price and share information. Price information must be included in the supplementary "data" slot.

Arguments

Objects from the Class

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

Slots

equity:

Object of class "numeric" containing the equity for this portfolio.e

file:

Object of class "character" containing the file from which this portfolio was loaded, if applicable.

price.var:

Object of class "character" containing the name of the column in the "data" slot to be used in share and weight calculations.

shares:

Object of class "data.frame" containing a data frame of shares for each position. Must have a unique column called "id".

name:

Object of class "character" containing the name for this portfolio.

instant:

Object of class "ANY" containing the instant to which the portfolio pertains.

data:

Object of class "data.frame" containing supplementary information about the positions in this portfolio. Must include a unique "id" column.

id.var:

Object of class "character" containing the name of the column in the data slot to be used as a unique identifier.

symbol.var:

Object of class "character" containing the name of the column in the "data" slot to be used as a descriptive symbol.

in.var:

Object of class "character" containing the name of the column in the "data" slot to be used as a rank vector in calls to create.

weight.var:

Object of class "character" containing the name of the column in the "data" slot to be used as weight overrides in calls to create.

weight.style:

Object of class "character" specifying how to calculate weights in this portfolio. Valid entries are:

  • "sides.separate": The default. Calculate weight of a position with respect to the total market value of positions on the same side.

  • "long.tmv": Calculate weight of a position with respect to the total market value of long positions.

  • "short.tmv": Calculate weight of a position with respect to the (positive) total market value of short positions.

  • "reference.equity": Calculate weight of a position relative to the reference equity in the equity slot. The equity slot must contain a numeric vector of length 1 for this style.

ret.var:

Object of class "character" containing the name of the column in the "data" slot to be used as the return in calls to performance.

type:

Object of class "character" containing the type of weight formation to use in calls to create. May be one of "relative", "equal", "linear", "sigmoid", "centroid", or "complex". Defaults to equal.

size:

Object of class "characterOrNumeric" containing the size of the portfolio to use in calls to create. May either contain the number of securities per side or one of "decile", "quintile", "quartile", "tercile", or "demile". Defaults to quintile.

weights:

Object of class "data.frame" containing the data frame of weights for this portfolio's positions. Must contain a unique column called "id".

Extends

Class "portfolioBasic", directly.

Methods

+

signature(e1 = "portfolio", e2 = "portfolio")

all.equal

signature(target = "portfolio", current = "portfolio"): Compare two portfolio objects for "near equality". Two portfolio objects are all.equal iff they are all.equal as portfolioBasic objects, their shares slots contain exactly the same set of securities and shares vectors that are all.equal.

calcShares

signature(object = "portfolio"): calculate shares from price and weight information, and store the results in the shares slot.

calcWeights

signature(object = "portfolio"): calculate weights from share and price information, and store the results in the weights slot.

create

signature(object = "portfolio"): create a portfolio object in the same manner as portfolioBasic, but also compute share amounts.

expandData

signature(object = "portfolio"): ...

expose

signature(object = "portfolio", trades = "trades"): ...

getYahooData

signature(object = "portfolio", symbol.var = "character"): ...

performance

signature(object = "portfolio"): ...

securityInfo

signature(object = "portfolio", id = "character"): display information about position id within this portfolio.

getYahooData

signature(object = "portfolio", symbol.var = "character"): Returns data for P/E Ratio, Book Value, Market Cap, Price/Book, and Price/Sales.

updatePrices

signature(object = "portfolio", id = "character", price = "numeric"): ...

Author

Jeff Enos jeff@kanecap.com