joshuaulrich / IBrokers

R API to Interactive Brokers Trader Workstation
65 stars 54 forks source link

reqHistoricalData does not work due to differing timezones #11

Open kylebalkissoon opened 8 years ago

kylebalkissoon commented 8 years ago

reqHistoricalData when called without an endDateTime passed grabs the current time from reqCurrentTime and then passes it back to IB as the endDateTime with the GMT timezone.

This will not work if the IBGateway is in a non GMT timezone specifically EDT.

library(IBrokers)
IBConn=ibgConnect(1234)
Contract2get = twsCurrency("EUR",currency = "JPY")
##Does not work
test = reqHistoricalData(IBConn,Contract = Contract2get,whatToShow ='BID_ASK',
  useRTH = "0",barSize = '1 min',duration="1 D")

##Works note my IBG is in EST
test = reqHistoricalData(IBConn,Contract = Contract2get,whatToShow ='BID_ASK',
  useRTH = "0",barSize = '1 min',duration="1 D",
  endDateTime = paste0(gsub("-","",reqCurrentTime(IBConn))," EST"))
joshuaulrich commented 8 years ago

I assume "Does not work" means there's an error; I can't replicate any error. Can you please provide the error message and the output from running traceback() after the error is thrown? Also, please provide the output from sessionInfo() and Sys.timezone(), and TWS version you're running.