tests/testthat/test-wfo_getdates.R

#
# test-wfo_getdates.R
# -------------------
#
#
library(ResilientPortfolio)
library(testthat)

context("Testing wfo_getdates")

test_that("Testing wfo_getdates function", {


  library(ResilientPortfolio)
  library(testthat)
  returns    = ROC(xts_data[, 1:5], type = "discrete")
  features   = c("mom84", "sd63", "sma10")
  rollwindow = 42 - 6 - 0
  wfo_span   = "months"
  wfo_offset = 0
  # wfo_offset = list(type = "runif", min = 0, max = 5)
  ####################

  x <- wfo_getdates(returns, features = features, rollwindow = rollwindow,
                    wfo_span = wfo_span, wfo_offset = wfo_offset)

  expect_equal(x[1], as.Date("2007-10-31"))

  rollwindow = 42 - 6 - 1
  x <- wfo_getdates(returns, features = features, rollwindow = rollwindow,
                    wfo_span = wfo_span, wfo_offset = wfo_offset)
  expect_equal(x[1], as.Date("2007-09-28"))


})
jeanmarcgp/ResilientPortfolio documentation built on April 8, 2018, 5:43 p.m.