I am trying to snap prices in R using the interactive brokers API for the latest price for a list of stocks (around 150). When I snap them for 2 stocks, it's almost instantaneous:
tickers<- c("YHOO","AAPL")
library("IBrokers")
t_start<-Sys.time()
tws <- twsConnect()
test<-reqMktData(tws, lapply(tickers, twsSTK), tickGenerics="", snapshot=T)
twsDisconnect(tws)
t_end<-Sys.time()
t_end-t_start
However, when I start adding more records into the tickers vector, it starts getting incredibly slow. For example:
tickers<-c("YHOO","AAPL","COP","PEP","XOM","ORCL","SPG","EQR","CVX","JPM","AFL","GIS","VZ","KMB","WFC","ROST","MMC")
This becomes excruciatingly slow.
I cannot figure out why it's so slow based on exchange, or size of company, as these are all large cap, highly liquid, blue chip stocks.
Is anyone familiar with why this is so slow?
Thank you very much.