reqHistoricalData: tzone argument does not seem to work correctly
GoogleCodeExporter opened this issue · 2 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
My local timezone is GMT+2. However, I want to use America/Chicago for
subsequent operations. Which works with standard time operations like
Sys.time(). Here is the discrepancy.
> Sys.timezone()
[1] "America/Chicago"
> spy = reqHistoricalData(tws, twsEquity("SPY"), barSize="5 mins",
duration="600 S", tzone="America/Chicago")
TWS Message: 2 -1 2100 API client has been unsubscribed from account data.
waiting for TWS reply on SPY .... done.
> spy
SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.WAP SPY.hasGaps SPY.Count
2014-08-08 00:40:00 192.22 192.30 192.19 192.26 3793 192.233
0 757
2014-08-08 00:45:00 192.26 192.36 192.19 192.21 4364 192.286
0 743
2014-08-08 00:50:00 192.19 192.27 192.14 192.22 3420 192.211
0 673
> Sys.time()
[1] "2014-08-07 18:54:58.144836 CDT"
> index(spy)
[1] "2014-08-08 00:40:00 CDT" "2014-08-08 00:45:00 CDT" "2014-08-08 00:50:00
CDT"
> spy = reqHistoricalData(tws, twsEquity("SPY"), barSize="5 mins",
duration="600 S")
waiting for TWS reply on SPY .... done.
> spy
SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.WAP SPY.hasGaps SPY.Count
2014-08-08 00:45:00 192.26 192.36 192.19 192.21 4364 192.286
0 743
2014-08-08 00:50:00 192.19 192.27 192.14 192.18 3898 192.208
0 751
2014-08-08 00:55:00 192.19 192.22 192.13 192.15 2483 192.174
0 445
What is the expected output? What do you see instead?
It seems like you're trying to diff the time, but that doesn't seem to work. I
couldn't find a way to fix this yet.
It seems to think that GMT+1 (?) is equal to America/Chicago. Completely
unexpected at any rate. Somehow time zone information is lost.
> Sys.setenv(TZ="Europe/Istanbul")
> Sys.time()
[1] "2014-08-08 03:01:04.078636 EEST"
What version of the product are you using? On what operating system?
0.9-10 on OS X
Please provide any additional information below.
You can mail me privately if you'd like. Cheers!
Original issue reported on code.google.com by examach...@gmail.com
on 8 Aug 2014 at 12:01
GoogleCodeExporter commented
Yes, I've verified that the function works correctly iff TZ="GMT"
Original comment by examach...@gmail.com
on 8 Aug 2014 at 12:16
GoogleCodeExporter commented
This may help finding the error. After I set the time zone to the correct time
zone:
Browse[3]> Sys.setenv(TZ="Europe/Istanbul")
Browse[3]> Sys.time()
[1] "2014-08-08 03:01:04.078636 EEST" # CORRECT TIME
Browse[3]> reqHistoricalData(tws, twsEquity("SPY"), barSize="5 mins",
duration="600 S", tzone="UTC")
waiting for TWS reply on SPY .... done.
SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.WAP SPY.hasGaps SPY.Count
2014-08-07 21:50:00 192.19 192.27 192.14 192.18 3898 192.208
0 751
2014-08-07 21:55:00 192.19 192.22 192.06 192.11 4079 192.150
0 741
2014-08-07 22:00:00 192.10 192.22 192.08 192.21 4242 192.148
0 738
Browse[3]> reqHistoricalData(tws, twsEquity("SPY"), barSize="5 mins",
duration="600 S", tzone="America/Chicago")
waiting for TWS reply on SPY .... done.
SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.WAP SPY.hasGaps SPY.Count
2014-08-07 16:55:00 192.19 192.22 192.06 192.11 4079 192.150
0 741
2014-08-07 17:00:00 192.10 192.22 192.08 192.19 4253 192.148
0 741
2014-08-07 17:05:00 192.22 192.22 192.16 192.17 369 192.189
0 63
This is not the correct time for Chicago:
Browse[3]> Sys.setenv(TZ="America/Chicago")
Browse[3]> Sys.time()
[1] "2014-08-07 19:08:35.706916 CDT"
So, the ONLY way to get the correct results is to set TZ to GMT, which doesn't
make any sense :(
Original comment by examach...@gmail.com
on 8 Aug 2014 at 12:09