[R-SIG-Finance] timestamps IBrokers

Stephen Choularton @tephen @ending from org@nicfoodm@rket@@com@@u
Tue Nov 20 20:05:18 CET 2018


Hi

I'm trying to figure out the time stamps

I am in Sydney.

If I use:

tws = twsConnect()
contract <- twsContract(0,'GC', "FUT", 
'NYMEX','','20181227',"0.0","USD","","","",NULL,NULL,"0")
reqHistoricalData(tws, contract, duration = "3600 S", barSize="1 min", 
useRTH=0) #1 = mkt hours only, 0 = anytime
closeAllConnections()

I get  long list of which this is a part:

2018-11-20 19:29:00    1226.3    1226.4   1226.2 1226.2          88  
1226.24            0         35
2018-11-20 19:30:00    1226.2    1226.4   1226.1 1226.2         131  
1226.25            0         63
2018-11-20 19:31:00    1226.2    1226.3   1226.1 1226.1         106  
1226.23            0         43
2018-11-20 19:32:00    1226.1    1226.2   1225.8 1225.9         130  
1225.96            0         64
2018-11-20 19:33:00    1225.9    1226.0   1225.8 1225.9         106  
1225.94            0         60

If I use reqMktData and then log the stream of data I get is a long list 
of which this is part:

2018-11-21 	05:31:54.728322 	1221.5
2018-11-21 	05:31:56.41735 	1221.5
2018-11-21 	05:31:57.712608 	1221.5
2018-11-21 	05:31:59.008863 	1221.5
2018-11-21 	05:32:00.279135 	1221.5
2018-11-21 	05:32:01.555404 	1221.5
2018-11-21 	05:32:03.279417 	1221.6
2018-11-21 	05:32:04.702601 	1221.6
2018-11-21 	05:32:05.589896 	1221.6

The closing price here is being picked out with:

Last_1_1 <- as.numeric(eWrapper$.Data$data[[1]][,5])

which I hope is the correct data item.

Of course I want to align the data.  The hours in the time stamp are 
different - reqMktData is time stamping with my local time (Sydney) but 
19:32 in not the time here or in NY where it is 13:32 if my arithmetic 
is correct.

Can anyone give me guidance on where that time stamp comes from?

Second the close from reqMktData just towards the end of 31 seconds 
(05:31:59.008863) shows a closing price of  1221.5 but the closing price 
from reqHistoricalData at 31 second was 1226.2 and at 32 second was 
1225.9 both several dollars away from the reqMktData figure.

Can anyone give me guidance why these two figures are not much closer 
together.  Have I got the wrong data item (eWrapper$.Data$data[[1]][,5]) 
or have I misunderstood <20181121 06:00:56.150975> id=1 symbol=GC 
closePrice: 1225.30  as being the closing price data that is returned by 
reqMktData.

Thanks

Stephen Choularton PhD, FIoD



More information about the R-SIG-Finance mailing list