开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

reqHistoricalData returns live data with date in the future


 

Hi all

As topic title, have a bit of an unusual one. So sometimes IBKR returns live daily data with date in the future, has anyone come across this problem?

I can handle it easily by restarting Gateway, but it irks me to no end that it happens, and more importantly I'm concerned that I have missed something somewhere that will manifest in a much nastier way down the track.

To illustrate the problem, on this just past Friday (1st July):
Using IBC, I run my script at 845am AEST(Sydney), and using reqHistoricalData it backfills daily data correctly up to and including 30th of June, and then it sits quietly until 10am (AEST) for market open to update me with live data.

-------------------------------------------
2022-07-01 08:45:25.529 [GS] INFO? [JTS-PostAuthenticateS2-23] - Started on 20220630-22:45:25
2022-07-01 08:45:25.529 [GS] INFO? [JTS-PostAuthenticateS2-23] - Default timezone:Australia/Sydney name:Australian Eastern Standard Time (New South Wales) dst:3600000
/////////////////////TRUNCATED///////////////////////////////
2022-07-01 09:59:53.444 [GS] INFO? [JTS-CCPDispatcherS2-35] - CCP reported time: 2022-06-30 23:59:53.000 (GMT) [1656633593000], local time: 2022-06-30 23:59:53.442 (GMT), local time: 2022-07-01 09:59:53.442 (AEST), difference in seconds: -0.442, handling delta:0 [Msg1]
2022-07-01 10:00:11.010 [GS] INFO? [JTS-EServerSocketNotifier-93] - [1:157:157:1:0:90:-1:INFO] Sending historical data update [requestId: 2]...
2022-07-01 10:00:11.012 [GS] INFO? [JTS-EServerSocketNotifier-93] - [1:157:157:1:0:90:-1:DET] [90;2;541;20220702;40.830;40.740;40.840;40.710;40.82844666903462;413859]
-------------------------------------------

As a test, I sat and watched it feed me data from the '2nd of July' for more than an hour before manually handling it.

It seems that the Gateway reads my login screen settings correctly and knows that my computer is in AEST timezone, and gives me historical data correctly, but when it returns live data, it adds 1 day to the date which in this case, the 2nd of July being a Saturday and therefore not a trading day, makes no sense.

From my understanding of the IBKR github, with reqHistoricalData and keepUpToDate=True, there is no way to set a timezone as it just reads off the TWS login screen. I have checked my TWS login screen timezone, Windows timezone settings, combed through this group's topics as well as done a code review and nothing has come to mind.

If this wasn't an intermittent problem then I would just subtract 1 from the date to make it work properly or perhaps use reqRealTimeBars, but the fact that restarting Gateway can usually resolve this problem suggests to me the issue is somewhere else.

Has anyone else come across this or have any ideas/thoughts?

Cheers and thanks in advance

Join [email protected] to automatically receive all group messages.