minute bar time stamp alignment

Issue #7 resolved
George W. created an issue

The convention is to align with the start of the bar period, not the end. But the following line of code returns 1-min bars that align with the end of the bar period. I don't have access to IQFeed's API documentation and not sure if this is by design or not.

If possible, could you kindly look into this and shift the time stamps by 1 period from end to start? e.g. "2016-08-18 18:01:00 2183.50 2183.75 2183.25 2183.50 347" should be "2016-08-18 18:00:00 2183.50 2183.75 2183.25 2183.50 347"

Thanks a lot!

ESU16 <- get_iqfeed_data('@ESU16', '2016-08-18 18:00:00', '2016-08-19 17:00:00', '1min')

time open high low close volume 2016-08-18 18:01:00 2183.50 2183.75 2183.25 2183.50 347 2016-08-18 18:02:00 2183.75 2184.00 2183.75 2184.00 108 2016-08-18 18:03:00 2184.00 2184.00 2183.75 2183.75 91 ... ... 2016-08-19 16:58:00 2182.00 2182.25 2182.00 2182.25 217 2016-08-19 16:59:00 2182.25 2182.25 2182.00 2182.00 173 2016-08-19 17:00:00 2182.25 2182.50 2182.00 2182.50 237

Comments (3)

  1. Stanislav Kovalevsky repo owner

    The time stamps for the data are on the close of the bar and I wouldn't recommend changing it but if you want you could change it this way:

    intraday.data <- get_iqfeed_data( symbol, from, to, period = 'hour' )
    if( !is.null( intraday.data ) ) intraday.data[, time := time - as.difftime( '01:00:00' ) ]
    

    In terms of data streams time of the bar is time it was formed i.e. 18:01 gives you summary of ticks came between (18:00,18:01] in case of 1min bars. Not a bug but I agree I should have added a note somewhere in documentation.

  2. George W. reporter

    Stanislav, thanks for the confirmation and suggestion! I will try your suggested approach and adjust the timestamp to match the convention of my other program and data sources.

  3. Log in to comment