backtest: Backtest a Set of Daily Weights

Description Usage Arguments Examples

Description

Backtest function that returns a daily NAV dataset

Usage

1
2
backtest(data, name = ".backtest", rebal_group_by = "date",
  rebal_ith = 1, prices = tidalprice::dailyclose)

Arguments

data

a data.frame containing the columns: symbol, date, w

name

a string name for the backtest results.

rebal_group_by

Optional Character indicating by group to apply to ith_date. Acceptable values are: date, week, month, qtr. Default is date which performs a daily rebalance.

rebal_ith

Optional Integer to determine which observation of each by group to return. For Example ith_date = 2, week will return the second day of each week. Also, ith_date = 99, month will return last day of each month. Default is 1.

prices

a data.frame containing the columns: symbol, date, price. Default is tidalprices::dailyclose.

Examples

1
2
3
4
5
6
7
8
9
# Create a data.frame of weights
df_weights <- dplyr::filter(tidalprice::dailyclose,
                            symbol %in% c('XLB', 'XLE', 'XLF'),
                            date <= as.Date('1998-12-31'))
df_weights$w <- 0.32
df_weights$price <- NULL

# Trade the weights
df_nav <- backtest(df_weights)

jmuhlenkamp/tidalbacktest documentation built on May 17, 2019, 7:45 a.m.