tests/testthat/tests_Portfolio.R

library(testthat)

context("Portoflio.IC test")
test_that("Portoflio.IC test", {
  data("sp500")
  X = sp500[1:300,1:100]
  t = NROW(X)
  n = NCOL(X)
  result_ic = hofa::Portfolio.IC(X,r=20,Port_obj = "EU",Adjcov = "LI")

  expect_equal(tail(result_ic$obj,1),5.67488795465,tolerance = 10^-6)

})

context("Portoflio.PC test")
test_that("Portoflio.PC test", {
  data("sp500")
  X = sp500[1:300,1:100]
  t = NROW(X)
  n = NCOL(X)
  result_pc = hofa::Portfolio.PC(X,r=20,Port_obj = "EU",Adjcov = "LI")

  expect_equal(tail(result_pc$obj,1),5.86548178441,tolerance = 10^-6)

})
GuanglinHuang/hofa documentation built on Sept. 3, 2023, 7:01 a.m.