make_equitycurve: Builds equity curves based on a daily timer and a set of...

Description Usage Arguments Details Value

Description

An xts matrix of an asset price and a binary timer is provided, along with a list of rules for converting the daily binary timer into equity curves. Each list objet in the set of rules corresponds to an equity curve. Both long only and long-short equity curves are returned.

Usage

1
make_equitycurve(data, rules, Nlag = 1)

Arguments

data

An xts matrix consisting of 2 columns. The asset prices in the first column and an associated timer in the second column. The timer may be binary or trinary. If more than two columns are provided, only the first two are used.

rules

A list of rules associated with each equity curve to generate from the daily timer. Each list object consist of a named list which names the equity curve and contains the rules to construct that equity curve. The first item on each named list must be the name of the ruleset to follow, and other items are its arguments, which may be optional. Currently supported rules include the following:

  • "endpoints" Uses the endpoints function to generate the equity curve. Optional additional arguments include the value for on (default = "weeks"), and the value for k (default = 1). See function xts::endpoints for details.

  • "runsum" NOT IMPLEMENTED - applies a running sum function (using rollapplyr) to count the number or occurences of a state before deciding which state to apply. If the summation count is not met, then the previous value stays, thereby implementing memory and hysteresis if the thresholds are properly chosen. Additional optional arguments are as follows, in order: up, an integer counting the number of the

  • "sma" implements a rolling mean (an SMA) over a window on the binary timer, so the real valued SMA will be a number between 0 and 1 inclusive. Parameters include window specifying the rolling window size (default = 10), up, specifying the sma threshold to declare a timer value of 1 (default = 0.5), and dn, which specifies the sma threshold to declare a timer value of 0 (default = 0.5). It is possible to implement hysteresis by setting a value of up that is higher than the value for dn. If the value of up is LESS than dn, then the system is unstable and oscillation will result.

Nlag

Number of days to lag the timer. Default is 1.

Details

Supported rules include perioding endpoints with optional offsets, and a running sum of positives over a sliding window (sma rule), where the thresholds for an up or down call can be set independently enabling to implement hysteresis.

NOTE: Trinary timers are not yet supported.

Value

Returns a list containting xts matrices of the timers, a long only equity curve and a long-short equity curve.

$long

An xts matrix containing the equity curves associated with each timer method, computed daily, and long when the post-processed timer is positive, or in cash otherwise (without earning any interest). The normalized asset price equity curve is also included to enable an easy comparison.

$longshort

An xts matrix containing the equity curves associated with each timer method, computed daily, and long when the post-processed timer is positive, or short otherwise. The normalized asset price equity curve is also included to enable an easy comparison.

$timers

An xts matrix containing the binary timers associated with each timer rule, computed daily.


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