inst/tests/test_paramsets.R

require(testthat)
context("paramset warnings")

options(in_test=TRUE)

require(quantstrat)
strategy.st <- "paramset_test"
strategy(strategy.st, store=TRUE)
.timespans <- c("T08:00/T10:00")

add.distribution(strategy.st,
	paramset.label = 'Timespan',
	component.type = 'enter',
	component.label = 'EnterLONG',
	variable = list(timespan = .timespans),
	label = 'Timespan')

test_that("Replacing paramset distribution warns", expect_warning({
    add.distribution(strategy.st,
	    paramset.label = 'Timespan',
	    component.type = 'enter',
	    component.label = 'EnterLONG',
	    variable = list(timespan = .timespans),
	    label = 'Timespan')
}))

add.distribution.constraint(strategy.st,
    paramset.label = 'Timespan',
    distribution.label.1 = 'EnterLong',
    distribution.label.2 = 'EnterShort',
    operator = '==',
    label = 'Timespan')

test_that("Replacing paramset constraint warns", expect_warning({
    add.distribution.constraint(strategy.st,
	    paramset.label = 'Timespan',
	    distribution.label.1 = 'EnterLong',
	    distribution.label.2 = 'EnterShort',
	    operator = '==',
	    label = 'Timespan')
}))

test_that("Deleting unknown paramset warns", expect_warning({
  delete.paramset(strategy.st, "Timespans")
}))

Try the quantstrat package in your browser

Any scripts or data that you put into this service are public.

quantstrat documentation built on May 31, 2017, 2:35 a.m.