find.instrument: Find the primary_ids of instruments that contain certain...

Description Usage Arguments Value Author(s) See Also Examples

Description

Uses regular expression matching to find instruments

Usage

1
2
find.instrument(text, where = "anywhere", Symbols = ls_instruments(),
  ignore.case = TRUE, exclude = NULL, ...)

Arguments

text

character string containing a regular expression. This is used by grep (see also) as the pattern argument.

where

if “anywhere” all levels/attributes of the instruments will be searched. Otherwise, where can be used to specify in which levels/attributes to look. (e.g. c("name", "description") would only look for text in those 2 places.

Symbols

the character ids of instruments to be searched. All are are searched by default.

ignore.case

passed to grep; if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

exclude

character vector of names of levels/attributes that should not be searched.

...

other arguments to pass through to grep

Value

character vector of primary_ids of instruments that contain the sought after text.

Author(s)

Garrett See

See Also

buildHierarchy, instrument.table, regex

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
instruments.bak <- as.list(FinancialInstrument:::.instrument, all.names=TRUE)
rm_instruments(keep.currencies=FALSE)
currency("USD")
stock("SPY", "USD", description="S&P 500 ETF")
stock("DIA", "USD", description="DJIA ETF")
stock(c("AA", "AXP", "BA", "BAC", "CAT"), "USD", members.of='DJIA')
stock("BMW", currency("EUR"))
find.instrument("ETF")
find.instrument("DJIA") 
find.instrument("DJIA", "members.of")
find.instrument("USD")
find.instrument("EUR")
find.instrument("EUR", Symbols=ls_stocks())
find.instrument("USD", "type")

## Can be combined with buildHierachy
buildHierarchy(find.instrument("ETF"), "type", "description")

## Cleanup. restore previous instrument environment
rm_instruments(); rm_currencies()
loadInstruments(instruments.bak)

## End(Not run)

FinancialInstrument documentation built on May 2, 2019, 3:41 a.m.