Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
braverock
GitHub Repository: braverock/portfolioanalytics
Path: blob/master/inst/tests/test_max_Sharpe.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_Sharpe.R", package="PortfolioAnalytics"))
8
9
10
context("demo_max_Sharpe")
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 StdDev as an objective",
16
{ expect_that(init.portf$objectives[[2]]$name == "StdDev", is_true()) })
17
18
##### maxSR.lo.ROI #####
19
context("maxSR.lo.ROI")
20
21
test_that("maxSR.lo.ROI objective measure mean = 0.006062083",
22
{ expect_equal(as.numeric(extractObjectiveMeasures(maxSR.lo.ROI)$mean), 0.006062083, tolerance=1e-6) })
23
24
test_that("maxSR.lo.ROI objective measure StdDev = 0.008843188",
25
{ expect_equal(as.numeric(extractObjectiveMeasures(maxSR.lo.ROI)$StdDev), 0.008843188, tolerance=1e-6) })
26
27
##### maxSR.lo.RP #####
28
context("maxSR.lo.RP")
29
30
test_that("maxSR.lo.RP objective measure mean is numeric",
31
{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.RP)$mean), is_true()) })
32
33
test_that("maxSR.lo.RP objective measure StdDev is numeric",
34
{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.RP)$StdDev), is_true()) })
35
36
##### maxSR.lo.DE #####
37
context("maxSR.lo.DE")
38
39
test_that("maxSR.lo.DE objective measure mean is numeric",
40
{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.DE)$mean), is_true()) })
41
42
test_that("maxSR.lo.DE objective measure StdDev is numeric",
43
{ expect_that(is.numeric(extractObjectiveMeasures(maxSR.lo.DE)$StdDev), is_true()) })
44
45
46