example_dir <- tempfile("fi-symbol-data-")
dir.create(example_dir)
data_env <- new.env()
data_env$FI_EXAMPLE <- xts::xts(
cbind(
Close = c(100, 101, 102, 101),
Volume = c(1000, 1200, 900, 1100)
),
order.by = as.Date("2020-01-01") + 0:3
)
tryCatch(
{
saveSymbols.common(
Symbols = "FI_EXAMPLE",
base_dir = example_dir,
env = data_env
)
loaded_data <- getSymbols.FI(
Symbols = "FI_EXAMPLE",
dir = example_dir,
split_method = "common",
auto.assign = FALSE,
verbose = FALSE
)
stopifnot(
xts::is.xts(loaded_data),
NROW(loaded_data) == 4L,
identical(
colnames(loaded_data),
c("Close", "Volume")
)
)
loaded_data
},
finally = {
unlink(example_dir, recursive = TRUE)
}
)
Run the code above in your browser using DataLab