targetall: Backtest a Fixed-Allocation Trading Strategy

Description Usage Arguments Value References Examples

Description

Implements a trading strategy aimed at maintaining a fixed allocation to each of several funds, rebalancing when the effective allocations deviate too far from the targets.

Usage

1
2
3
targetall(tickers = NULL, intercepts = NULL, slopes = NULL, ...,
  tickers.gains = NULL, target.alls = NULL, tol = 0.05,
  rebalance.cost = 0, initial = 10000)

Arguments

tickers

Character vector of ticker symbols that Yahoo! Finance recognizes, if you want to download data on the fly.

intercepts

Numeric vector of values to add to daily gains for each ticker.

slopes

Numeric vector of values to multiply daily gains for each ticker by. Slopes are multiplied prior to adding intercepts.

...

Arguments to pass along with tickers to load_gains.

tickers.gains

Numeric matrix of gains, where each column has gains for a particular fund.

target.alls

Numeric vector specifying target allocations to each fund. If unspecified, equal allocations are used (e.g. 1/3, 1/3, 1/3 if there are 3 funds).

tol

Numeric value indicating how far the effective allocations can drift away from the targets before rebalancing.

rebalance.cost

Numeric value specifying total cost of each rebalancing trade.

initial

Numeric value specifying what value to scale initial prices to.

Value

List containing:

  1. Numeric matrix named fund.balances giving fund balances over time.

  2. Numeric value named rebalance.count giving the number of rebalancing trades executed.

References

Ryan, J.A. and Ulrich, J.M. (2017) quantmod: Quantitative Financial Modelling Framework. R package version 0.4-12, https://CRAN.R-project.org/package=quantmod.

Examples

1
2
3
4
5
6
## Not run: 
# Backtest equal-allocation UPRO/VBLTX/VWEHX strategy
port <- targetall(tickers = c("UPRO", "VBLTX", "VWEHX"))
plot(port$fund.balances[, "Portfolio"])

## End(Not run)

stocks documentation built on May 2, 2019, 9:43 a.m.

Related to targetall in stocks...