Path: blob/master/inst/tests/test_max_Sharpe.R
1433 views
1##### Load packages #####2require(testthat)3require(PortfolioAnalytics)45##### Source Demo Script #####6source(system.file("demo/demo_max_Sharpe.R", package="PortfolioAnalytics"))789context("demo_max_Sharpe")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 StdDev as an objective",15{ expect_that(init.portf$objectives[[2]]$name == "StdDev", is_true()) })1617##### maxSR.lo.ROI #####18context("maxSR.lo.ROI")1920test_that("maxSR.lo.ROI objective measure mean = 0.006062083",21{ expect_equal(as.numeric(extractObjectiveMeasures(maxSR.lo.ROI)$mean), 0.006062083, tolerance=1e-6) })2223test_that("maxSR.lo.ROI objective measure StdDev = 0.008843188",24{ expect_equal(as.numeric(extractObjectiveMeasures(maxSR.lo.ROI)$StdDev), 0.008843188, tolerance=1e-6) })2526##### maxSR.lo.RP #####27context("maxSR.lo.RP")2829test_that("maxSR.lo.RP objective measure mean is numeric",30{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.RP)$mean), is_true()) })3132test_that("maxSR.lo.RP objective measure StdDev is numeric",33{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.RP)$StdDev), is_true()) })3435##### maxSR.lo.DE #####36context("maxSR.lo.DE")3738test_that("maxSR.lo.DE objective measure mean is numeric",39{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.DE)$mean), is_true()) })4041test_that("maxSR.lo.DE objective measure StdDev is numeric",42{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.DE)$StdDev), is_true()) })43444546