make_bench: Create an asset benchmark timer from a standard indicator and...

Description Usage Arguments Details Value Examples

Description

This function is a wrapper for make_timer(). It simplifies the creation of an asset benchmark timer in a simpler function call.

Usage

1
2
make_bench(data, type = "Goldencross", retval = "timedec",
  on = "days", offset = 0, seriestype = "prices", ...)

Arguments

data

The xts matrix containing the asset price series in the FIRST column.

type

A vector of character strings specifying the type of benchmark to calculate. Possible values include any of the following:

  • 'Goldencross': The standard asset price SMA50 / SMA200 days.

  • 'Faber10': The 210 days (10 months) price momentum, calculated daily. Normally sampled monthly at end of months, so on = 'months' should be specified.

  • 'Dema50': The StormGuard DEMA 50 implementation, with the 22 multiplier of daily returns and 0.006 offset.

  • 'Minidipper': Implements the timer in the Mini Dipper strategy. A crossover of price EMA65 / SMA200.

retval

A vector specifying which columns to return. Values can include any set of: c('timer', 'timerlag', 'ec', 'timedec', 'rets', 'timedrets'). See make_timer() retval parameter for details.

on

The period at which the timer is sampled to make its decision. These can be one of: 'days', 'weeks', 'months' or 'quarters'. Default is 'days'.

offset

The number of periods to add to offset the sampling dates, as specified by the on parameter. Default is 0.

seriestype

The type of asset series data provided in column 1. Can be either 'rets' or 'prices'. If 'rets', then discrete returns are assumed. If 'prices', then prices are assumed. Default is 'prices'.

Details

The argument data contains an xts price series only. If data contains more than one column, then only the first column is used. The argument type is used to specify what timer to use, as an easy to remember string. Multiple timers can be used if type is passed as a vector of strings.

Value

An xts matrix with columns specified by parameter retval.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
ec <- xts_data[, 'SPY']
ec$Goldencross <- make_bench(xts_data[, 'SPY'], type = 'Goldencross', retval = 'timedec')
ec$Dema50      <- make_bench(xts_data[, 'SPY'], type = 'Dema50', retval = 'timedec')
ec$Faber10     <- make_bench(xts_data[, 'SPY'], type = 'Faber10', retval = 'timedec')
xtsplot(ec, main = 'SPY and its daily timers')

ecm <- xts_data[, 'SPY']
ecm$Goldencross <- make_bench(xts_data[, 'SPY'], type = 'Goldencross', on = 'months', retval = 'ec')
ecm$Dema50 <- make_bench(xts_data[, 'SPY'], type = 'dema50', on = 'months', retval = 'ec')
ecm$Faber10 <- make_bench(xts_data[, 'SPY'], type = 'Faber10', on = 'months', retval = 'ec')
xtsplot(ecm, main = 'SPY and its monthly timers')

ecset <- xts_data[, 'SPY']
ecset$GoldenCross <- make_bench(xts_data[, 'SPY'], type = 'goldencross', on = 'months', retval = 'ec', offset=4)
xtsplot(ecset, main = 'SPY and 4 day offset monthly Golden Cross')

jeanmarcgp/xtsanalytics documentation built on May 19, 2019, 12:38 a.m.