tests/testthat/test-stockDataDownload.R

context("Checking online data downloading")

test_that("the embedded SP500 symbols are the same", {
  sink(file = tempfile())
  stockData <- stockDataDownload(c("AAPL"), from = "2018-01-01", to = "2018-01-30", local_file_path = NULL)
  sink()
  stockData <- as.numeric(lapply(stockData, mean))
  stockDataDownload_check <- quantmod::getSymbols("AAPL", from = "2018-01-01", to = "2018-01-30", auto.assign = FALSE)
  expect_equal(as.numeric(lapply(stockData, mean)), as.numeric(colMeans(stockDataDownload_check)), tolerance = 1e-5)
})

Try the portfolioBacktest package in your browser

Any scripts or data that you put into this service are public.

portfolioBacktest documentation built on April 22, 2022, 9:05 a.m.