getPortfolioPrices: Generate portfolio prices using the fractal process

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/framework.R

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

1
2
3
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.

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.

Value

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

Note

In the future, it may be possible to generate time series with an explicit R/S value or Hurst exponent.

Author(s)

Brian Lee Yung Rowe

Examples

1
2
3
4
5
  data(generators)
  ps <- getPortfolioPrices('IBM', '2009-02-24',obs=10,
    seeds=sampleInitiators, patterns=sampleGenerators)

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

Example output

Loading required package: futile.any
Loading required package: lambda.r
Loading required package: futile.logger
Loading required package: timeDate
Loading required package: quantmod
Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.
 [1] "2009-02-13" "2009-02-16" "2009-02-17" "2009-02-18" "2009-02-19"
 [6] "2009-02-20" "2009-02-23" "2009-02-24" "2009-02-25" "2009-02-26"

fractalrock documentation built on May 29, 2017, 7:10 p.m.