Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
braverock
GitHub Repository: braverock/portfolioanalytics
Path: blob/master/inst/tests/test_demo_max_STARR.R
1433 views
1
2
##### Load packages #####
3
require(testthat)
4
require(PortfolioAnalytics)
5
6
##### Source Demo Script #####
7
source(system.file("demo/demo_max_STARR.R", package="PortfolioAnalytics"))
8
9
10
context("demo_max_STARR")
11
12
test_that("init.portf contains mean as an objective",
13
{ expect_that(init.portf$objectives[[1]]$name == "mean", is_true()) })
14
15
test_that("init.portf contains ES as an objective",
16
{ expect_that(init.portf$objectives[[2]]$name == "ES", is_true()) })
17
18
test_that("init.portf contains ES as an objective with p=0.925",
19
{ expect_equal(init.portf$objectives[[2]]$arguments$p, 0.925) })
20
21
##### maxSR.lo.ROI #####
22
context("maxSTARR.lo.ROI")
23
24
test_that("maxSTARR.lo.ROI objective measure mean = 0.006657183",
25
{ expect_equal(as.numeric(extractObjectiveMeasures(maxSTARR.lo.ROI)$mean), 0.006657183, tolerance=1e-6) })
26
27
test_that("maxSTARR.lo.ROI objective measure ES = 0.01394436",
28
{ expect_equal(as.numeric(extractObjectiveMeasures(maxSTARR.lo.ROI)$ES), 0.01394436, tolerance=1e-6) })
29
30
##### maxSTARR.lo.RP #####
31
context("maxSTARR.lo.RP")
32
33
test_that("maxSTARR.lo.RP objective measure mean is numeric",
34
{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.RP)$mean), is_true()) })
35
36
test_that("maxSTARR.lo.RP objective measure ES is numeric",
37
{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.RP)$ES), is_true()) })
38
39
##### maxSTARR.lo.DE #####
40
context("maxSTARR.lo.DE")
41
42
test_that("maxSTARR.lo.DE objective measure mean is numeric",
43
{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.DE)$mean), is_true()) })
44
45
test_that("maxSR.lo.DE objective measure StdDev is numeric",
46
{ expect_that(is.numeric(extractObjectiveMeasures(maxSTARR.lo.DE)$ES), is_true()) })
47
48