initPortf: Initializes a portfolio object.

Description Usage Arguments Details Author(s)

View source: R/initPortf.R


Constructs and initializes a portfolio object, which is used to contain transactions, positions, and aggregate level values.


initPortf(name = "default", symbols, initPosQty = 0,
  initDate = "1950-01-01", currency = "USD", ...)



A name for the resulting portfolio object


A list of instrument identifiers for those instruments contained in the portfolio


Initial position quantity, default is zero


A date prior to the first close price given, used to contain initial account equity and initial position


ISO currency identifier used to locate the portfolio currency


any other passthrough parameters


Initializes a portfolio object, which is constructed from the following: $symbols: the identifier used for each instrument contained in the portfolio. Use ls(Portfolio$symbols) to get a list of symbols. $symbols$[symbol]$txn: irregular xts object of transactions data $symbols$[symbol]$posPL: regular xts object of positions P&L calculated from transactions $symbols$[symbol]$posPL.ccy: regular xts object of positions P&L converted to portfolio currency $summary: aggregated portfolio values

Each symbol has three associated tables. The first, txn, is the transactions table, an irregular time series that contains information about trades or other position adjustments with the following columns:

The second, posPL, is a container used to store calculated P&L values from transactions and close prices within an instrument. The data series is, however, a regular time series. Columns of the table include:

The third, posPL.ccy, is the same as the second but translated into the portfolio currency.

For each portfolio, the summary slot contains a table that tracks calculated portfolio information through time. The table contains the following columns, held in a regular xts time series:

TODO: add $account: name of the (one) affiliated account Outputs Initialized portfolio structure with a start date and initial positions.


Peter Carl

cloudcell/blotter documentation built on May 13, 2019, 8:01 p.m.