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:
|
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.
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.
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#> NULL# 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")#> # A tibble: 15 x 6 #> con_id symbol sec_type primary_exchange currency asset_types #> <chr> <chr> <chr> <chr> <chr> <list> #> 1 38709473 IBM STK MEXI MXN <chr [0]> #> 2 1411277 IBM STK IBIS EUR <chr [0]> #> 3 8314 IBM STK NYSE USD <chr [6]> #> 4 41645598 IBMUSD STK EBS USD <chr [0]> #> 5 205626661 IBMK STK ARCA USD <chr [0]> #> 6 163609161 IBMI STK ARCA USD <chr [0]> #> 7 205626656 IBMJ STK ARCA USD <chr [0]> #> 8 272692107 IBML STK BATS USD <chr [0]> #> 9 311679969 IBMM STK BATS USD <chr [0]> #> 10 341758684 IBMN STK BATS USD <chr [0]> #> 11 361208024 IBMQ STK BATS USD <chr [0]> #> 12 359815312 IBMO STK BATS USD <chr [0]> #> 13 360508598 IBMP STK BATS USD <chr [0]> #> 14 365190838 IBMFNIFTY STK NSE INR <chr [0]> #> 15 265861716 IBM.REC STK CARISK USD <chr [0]>#> # A tibble: 15 x 6 #> con_id symbol sec_type primary_exchange currency asset_types #> <chr> <chr> <chr> <chr> <chr> <list> #> 1 41645598 IBMUSD STK EBS USD <chr [0]> #> 2 38709473 IBM STK MEXI MXN <chr [0]> #> 3 1411277 IBM STK IBIS EUR <chr [0]> #> 4 8314 IBM STK NYSE USD <chr [6]> #> 5 6604892 PSB STK NYSE USD <chr [3]> #> 6 44263073 4733 STK TSEJ JPY <chr [1]> #> 7 39131134 2834 STK TAI TWD <chr [0]> #> 8 234647237 BBU STK NYSE USD <chr [2]> #> 9 235343043 BBU.UN STK TSE CAD <chr [2]> #> 10 48880606 RLIA STK BM EUR <chr [0]> #> 11 229728912 MOO STK ARCA USD <chr [4]> #> 12 260519091 147 STK SEHK HKD <chr [0]> #> 13 132897787 SV3U STK SGX SGD <chr [0]> #> 14 4726958 BBSI STK NASDAQ.NMS USD <chr [3]> #> 15 171642734 NEWT STK NASDAQ.NMS USD <chr [3]>#> # A tibble: 11 x 6 #> con_id symbol sec_type primary_exchange currency asset_types #> <chr> <chr> <chr> <chr> <chr> <list> #> 1 41645598 IBMUSD STK EBS USD <chr [0]> #> 2 38709473 IBM STK MEXI MXN <chr [0]> #> 3 1411277 IBM STK IBIS EUR <chr [0]> #> 4 8314 IBM STK NYSE USD <chr [6]> #> 5 295400721 M2Z STK FWB2 EUR <chr [0]> #> 6 146510035 MMX STK LSE GBP <chr [0]> #> 7 92870230 WINDMACHI STK NSE INR <chr [0]> #> 8 311885911 MACPOWER STK NSE INR <chr [0]> #> 9 56983469 LOKESHMAC STK NSE INR <chr [0]> #> 10 332653316 MARSHALL STK NSE INR <chr [0]> #> 11 265861716 IBM.REC STK CARISK USD <chr [0]>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)#> [1] "CFD" "OPT" "IOPT" "WAR" "FUT" "BAG"