API Support Forum
OEC API > Market Data > Historical Bar Timstamp is vulnerable to DST change
Author Topic: Historical Bar Timstamp is vulnerable to DST change
(1 messages, Page 1 of 1)
Moderators: VPfau
CWeber984
Posts: 226
Joined: Apr 24, 2012


Posted: Mar 26, 2014 @ 10:46 PM             Msg. 1 of 1
Using current OEC COM API 3.5 exe and its Cpp sample code, when I request historical daily bars (for ZCK4) like so:

OECAPI()->RequestHistory(con, 41705.0, nowUTC.m_dt);

The resulting bars show a timestamp impacted by the DST boundary (DST changed on 3/9/14):

3/6/2014 1:00:00 AM, 41704.0417, 4.8025, 4.9250, 4.7850, 4.9100
3/7/2014 1:00:00 AM, 41705.0417, 4.9000, 5.0250, 4.8450, 4.8725
3/10/2014, 41708.0000, 4.8650, 4.8775, 4.7550, 4.7700
3/11/2014, 41709.0000, 4.7700, 4.8500, 4.7325, 4.8425
.... to current datetime given by nowUTC.m_dt

41705.0 == 3.07.14 0:00:00 in UTC.

So we get the previous session's (Thursday) bar as the first returned historical bar. The OHLC values are good for all bars.

Our only problem is that we use a std::map with the bar timestamp as the key. Therefore, because we cache our histories, we now have 2 bars for the 3.6 and 3.7 sessions, because our daily bars normally have 0:00:00 as the time.

This is a deprecated Request according to the api documentation, so I tested the new recommended daily history request as well:

OECAPI()->RequestBars(con, 41705.0, nowUTC.m_dt, OECAPICOM::SubscriptionType_Bar, 1440);

This returned the same result.

Our fix is simple: truncate the bar->timestamp to remove the time data.

However, I thought you'd like to investigate why the Requests above are DST sensitive despite us making requests using UTC time.

Thanks,

CHW