example_ids <- c(
"FI_EXAMPLE_A",
"FI_EXAMPLE_B"
)
had_usd <- is.currency.name("USD")
tryCatch(
{
if (!had_usd) {
currency("USD")
}
metadata <- data.frame(
primary_id = example_ids,
type = c("stock", "stock"),
currency = c("USD", "USD"),
description = c(
"Example instrument A",
"Example instrument B"
),
stringsAsFactors = FALSE
)
load.instruments(metadata = metadata)
getInstrument("FI_EXAMPLE_A")
getInstrument("FI_EXAMPLE_B")
},
finally = {
rm_instruments(example_ids)
if (!had_usd) {
rm_currencies("USD")
}
}
)
Run the code above in your browser using DataLab