inst/tinytest/test_td.R

suppressMessages(library(td))

.onWindows <- .Platform$OS.type == "windows"

## there is not a lot we can without an API key
## because windoze is windoze this now errors so protecting it
if (! .onWindows) expect_error(time_series(sym="SPY", api=""))

## if we have an API key AND tests are opted-into, run basic tests
## we use an opt-in to not run down the query allotment
if ((Sys.getenv("RunTDTests","") == "yes")
    && td:::.get_apikey() != ""
    && requireNamespace("xts", quietly=TRUE)) {

    spy <- time_series(sym="SPY", interval="1min", outputsize=100, as="xts")

    expect_true(inherits(spy, "xts"))
    expect_equal(nrow(spy), 100)
}

Try the td package in your browser

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

td documentation built on Jan. 27, 2022, 1:16 a.m.