Learn R Programming

FinancialInstrument (version 1.4.1)

ls_by_currency: List instruments by currency denomination

Description

Returns the names of instruments denominated in one or more specified currencies.

Usage

ls_by_currency(currency, pattern = NULL, match = TRUE, show.currencies = FALSE)

rm_by_currency(x, currency, keep.currencies = TRUE)

ls_USD(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_AUD(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_GBP(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_CAD(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_EUR(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_JPY(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_CHF(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_HKD(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_SEK(pattern = NULL, match = TRUE, show.currencies = FALSE)

ls_NZD(pattern = NULL, match = TRUE, show.currencies = FALSE)

Value

A character vector containing instrument names denominated in the requested currencies, or `NULL` when no matching instruments are found.

Arguments

currency

Character vector containing the names of currencies.

pattern

An optional regular expression. Only instrument names matching `pattern` are returned.

match

Logical. Should `pattern` be matched exactly?

show.currencies

Logical. Should currency instruments themselves be included in the returned names?

x

Character vector of instrument names to remove. If missing, all instruments denominated in `currency` are selected.

keep.currencies

Logical. If `TRUE`, retain the currency instruments themselves.

Author

Garrett See

See Also

[ls_instruments()], [ls_currencies()], [rm_instruments()], [rm_currencies()], [instrument()]

Examples

Run this code
example_dir <- tempfile("fi-currency-")
dir.create(example_dir)

backup_name <- "backup.RData"
backup_path <- file.path(example_dir, backup_name)

saveInstruments(backup_name, dir = example_dir)

tryCatch(
  {
    rm_instruments(keep.currencies = FALSE)

    currency(c("USD", "CAD", "GBP"))
    stock(c("CM", "CNQ"), currency = "CAD")
    stock(c("BARC", "BET"), currency = "GBP")
    stock(c("DIA", "SPY"), currency = "USD")

    ls_by_currency("CAD")
    ls_by_currency("GBP")
    ls_USD()
    ls_CAD()

    rm_by_currency(currency = "CAD")

  },
  finally = {
    if (file.exists(backup_path)) {
      reloadInstruments(
        backup_name,
        dir = example_dir
      )
    }

    unlink(example_dir, recursive = TRUE)
  }
)

Run the code above in your browser using DataLab