View source: R/req_matching_symbols.R
req_matching_symbols | R Documentation |
Search Interactive Brokers' database for stocks (and stocks
only)
by specifying a search string pattern
. pattern
may be a ticker,
e.g. "AAPL", or part of a stock's name, e.g. "App".
req_matching_symbols(pattern, channel = NULL)
pattern |
Character vector of length 1. The search string for which matching stocks are sought. May be a ticker, e.g. "IBM", or part of a stock's name, e.g. "International". Not case sensitive. |
channel |
One of the following:
|
Space out calls to req_matching_symbols
() by at least 1
second. IB will only allow at most 1 call to req_matching_symbols
per
second per user, meaning that even if you run seperate searches for
matching symbols on different sockets at the same time, you'll get an error
telling you that IB is busy processing the request for a different client.
A tibble object in which each row corresponds to an asset whose name
or ticker matched the pattern
supplied. The tibble's columns are:
con_id
<chr>: Interactive Brokers' unique numeric ID
symbol
<chr>: Exchange symbol (i.e., ticker symbol)
sec_type
<chr>: Asset class ("STK" for stock)
primary_exchange
<chr>: Financial exchange on which most of
the asset's trade volume takes place (NYSE, ARCA, etc).
currency
<chr>: Currency in which trades are made.
asset_types
<list>: A list of other financial products
(options, bonds, warrants, etc) that derive from the asset and are
available to trade through Interactive Brokers.
Other asset info:
req_contract_details()
,
req_sec_def_opt_params()
# Fetch matching symbols for pattern "international"
matching_symbols <- req_matching_symbols("international")
# Print matching symbols
matching_symbols
# If that doesn't satisfy, try a few more search strings. Wait 3 seconds after
# each one so as to be kind to IB's servers.
req_matching_symbols("ibm")
Sys.sleep(3)
req_matching_symbols("business")
Sys.sleep(3)
req_matching_symbols("machines")
Sys.sleep(3)
# Say you only wanted to know what asset types -- futures, options, warrants,
# etc -- that were available for the stock traded on the NYSE under the symbol
# "IBM". You could pipe the output of req_matching_symbols() to a series of
# functions with the end result of returning only the info you want:
req_matching_symbols("ibm") %>%
dplyr::filter(symbol == "IBM" & primary_exchange == "NYSE") %>%
dplyr::select(asset_types) %>%
unlist(use.names = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.