Learn R Programming

fractalrock (version 1.1.0)

getPortfolioPrices: Generate portfolio prices using the fractal process

Description

This function will construct a portfolio of asset returns based on the time range specified or the number of 'observations' requested. The resulting time series will be based on the specified calendar, as defined by getTradingDates that uses the timeDate package under the hood.

Usage

getPortfolioPrices(symbols, obs = NULL, end = Sys.Date(), start = NULL, calendar = holidayNYSE, seeds = NULL, patterns = NULL, ..., type = "uniform")
getTradingDates(end, start = NULL, obs = NULL, calendar = holidayNYSE)

Arguments

symbols
The names of the assets to generate prices for. This determines the total number of time series generated.
end
The last date in the time series
start
The starting date of the time series. All non-business days are removed in the resulting range. Either start or obs must be set.
obs
The total number of points to generate. The dates will follow a business day calendar as defined by timeDate, defaulting to NYSE. Either start or obs must be set.
calendar
The business day calendar to use. Defaults to NYSE.
seeds
A list of initiators to use for generating the time series
patterns
A list of generators to use for generating the time series
...
Additional arguments to send to the fractal generator
type
The type of fractal process to use. Defaults to uniform.

Value

An xts object with either obs rows or points in the range [start,end] and a time series for each symbol provided.

Details

The main entry point is getPortfolioPrices, which generates a TxM xts object based on the symbols provided. Prices generated by this function can be used in risk modeling, as a substitute for brownian motion in Monte Carlo simulations, and backtesting applications. Studying fractal generation of time series can be accomplished more directly by calling fractal.

In addition to the arguments above, it is necessary to pass the appropriate arguments to the the underlying fractal call. This includes passing in a seed and generator patterns. If none are provided predefined sets will be used, although users of this package are encouraged to create their own initiators and generators.

The getTradingDates function is a utility to generate proper business days for a given calendar. This is used to be compatible with other applications that load actual asset data.

Examples

Run this code
  data(generators)
  ps <- getPortfolioPrices('IBM', '2009-02-24',obs=10,
    seeds=sampleInitiators, patterns=sampleGenerators)

  getTradingDates('2009-02-26', obs=10)

Run the code above in your browser using DataLab