1

I am trying to use R package IBrokers to get data on different symbols. When I initially did my tests the following line worked as expected

reqHistoricalData(tws, Contract=contract, barSize='1 min', duration='60 S')

But I found out it only works when the market is closed. I need realtime data.

On the other hand the following line

reqRealTimeBars(tws, contract, barSize='5')

Provides 5 second bar values, but it streams continually and I need to query multiple instruments. I could run multiple instances of the R script but it doesn't sound right.

Does anyone have any tip on how to access the values of the last realtime 1 minute bar?

Thanks

JordanBelf
  • 3,208
  • 9
  • 47
  • 80
  • 1
    If I use the first one while the market is open, I get intraday data. What market are you looking at? – GSee Jan 13 '15 at 15:14
  • In this case I was trying to retrieve AAPL, here is the error I am getting waiting for TWS reply on AAPL ....failed. `Warning message: In errorHandler(con, verbose, OK = c(165, 300, 366, 2104, 2106, : Historical Market Data Service error message:HMDS query returned no data: AAPL@SMART Trades` It does work as soon as the market closes – JordanBelf Jan 13 '15 at 15:19
  • 1
    hmm, I got it working by changing my line to the following `reqHistoricalData(tws, Contract=contract, barSize='1 min', duration='1 D')` which makes total sense... – JordanBelf Jan 13 '15 at 16:09

0 Answers0