sigFormula: generate a signal from a formula

Description Usage Arguments Details

Description

This code takes advantage of some base R functionality that can treat an R object (in this case the internal mktdata object in quantstrat) as an environment or 'frame' using parent.frame. This allows the columns of the data to be addressed without any major manipulation, simply by column name. In most cases in quantstrat, this will be either the price/return columns, or columns added by indicators or prior signals. The formula will return TRUE/FALSE for each row comparison as a time series column which can then be used for rule execution. The formula will be evaluated using eval as though in an if statement.

Usage

1
sigFormula(label, data = mktdata, formula, cross = FALSE)

Arguments

label

text label to apply to the output

data

data to apply formula to

formula

a logical expression like that used in an if statement, will typically reference column names in mktdata

cross

if TRUE, will return TRUE only for the first observation to match the formula in a run

Details

This code is adapted from the approach used by Vijay Vaidyanthan in his PAST(AAII/SIPRO) code to construct arbitrary, formulaic, comparisons. Many thanks to Vijay for sharing his expertise.


redmode/quantstrat documentation built on May 27, 2019, 4:04 a.m.