context("Test calcOpenGapCoefParallel")
test_that("function returns correct data.", {
start.date <- "2018-10-01"
end.date <- "2018-10-31"
symbols <- c("AAPL", "BRKB", "IBM", "INTL", "MSFT")
window <- 10
# data <- getSliceData(settings$sharadar.sqli,
# c("roc.pc2to", "roc.to2tc"),
# start.date, end.date, symbols, TRUE,
# NULL, NULL, NULL, NULL)
# saveRDS(data, paste0(system.file(package="myrlib"),
# "/testdata/data_calcOpenGapCoefParallel.rds"))
data <- readRDS(system.file("testdata/data_calcOpenGapCoefParallel.rds",
package = "myrlib"))
result <- calcOpenGapCoefParallel(window, data$roc.pc2to, data$roc.to2tc,
parallel = FALSE)
# Test names and dim
expect_equal(names(result), symbols)
expect_equal(nrow(result), 23)
expect_equal(ncol(result), length(symbols))
# Test types
expect_is(result, "xts")
expect_is(index(result), "POSIXct")
# Test values
expect_equal(as.numeric(result[end.date, "AAPL"]), -0.415255143)
expect_equal(head(index(result), 1), as.POSIXct(start.date))
expect_equal(tail(index(result), 1), as.POSIXct(end.date))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.