Description Usage Arguments Details Value Examples
This function is a wrapper for make_timer(). It simplifies the creation of an asset benchmark timer in a simpler function call.
1 2 | make_bench(data, type = "Goldencross", retval = "timedec",
on = "days", offset = 0, seriestype = "prices", ...)
|
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:
|
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'. |
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.
An xts matrix with columns specified by parameter retval.
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')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.