Path: blob/master/inst/tests/test_demo_max_STARR.R
1433 views
1##### Load packages #####2require(testthat)3require(PortfolioAnalytics)45##### Source Demo Script #####6source(system.file("demo/demo_max_STARR.R", package="PortfolioAnalytics"))789context("demo_max_STARR")1011test_that("init.portf contains mean as an objective",12{ expect_that(init.portf$objectives[[1]]$name == "mean", is_true()) })1314test_that("init.portf contains ES as an objective",15{ expect_that(init.portf$objectives[[2]]$name == "ES", is_true()) })1617test_that("init.portf contains ES as an objective with p=0.925",18{ expect_equal(init.portf$objectives[[2]]$arguments$p, 0.925) })1920##### maxSR.lo.ROI #####21context("maxSTARR.lo.ROI")2223test_that("maxSTARR.lo.ROI objective measure mean = 0.006657183",24{ expect_equal(as.numeric(extractObjectiveMeasures(maxSTARR.lo.ROI)$mean), 0.006657183, tolerance=1e-6) })2526test_that("maxSTARR.lo.ROI objective measure ES = 0.01394436",27{ expect_equal(as.numeric(extractObjectiveMeasures(maxSTARR.lo.ROI)$ES), 0.01394436, tolerance=1e-6) })2829##### maxSTARR.lo.RP #####30context("maxSTARR.lo.RP")3132test_that("maxSTARR.lo.RP objective measure mean is numeric",33{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.RP)$mean), is_true()) })3435test_that("maxSTARR.lo.RP objective measure ES is numeric",36{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.RP)$ES), is_true()) })3738##### maxSTARR.lo.DE #####39context("maxSTARR.lo.DE")4041test_that("maxSTARR.lo.DE objective measure mean is numeric",42{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.DE)$mean), is_true()) })4344test_that("maxSR.lo.DE objective measure StdDev is numeric",45{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.DE)$ES), is_true()) })464748