Details
Description
This is a follow up for a recent issue we had with our production system.
Few days after daylight switch in USA (which happened to be on November 2nd 2008) our system disconnected one hour early from the exchange.
Here is a little test case to illustrate:
public void testSettingsWithStartEndDayWithDST() throws Exception
{ SessionSettings settings = new SessionSettings(); settings.setString(Session.SETTING_TIMEZONE, "America/New_York"); settings.setString(Session.SETTING_START_DAY, DayConverter.toString(Calendar.SUNDAY)); settings.setString(Session.SETTING_START_TIME, "20:00:00"); settings.setString(Session.SETTING_END_DAY, DayConverter.toString(Calendar.FRIDAY)); settings.setString(Session.SETTING_END_TIME, "17:00:00"); // mockSystemTimeSource.setTime(getTimeStamp(2008, Calendar.NOVEMBER, 2, 18, 0, 0, // TimeZone.getTimeZone("America/New_York"))); SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET"); SessionSchedule schedule = new SessionSchedule(settings, sessionID); System.out.println(schedule); //November,2 -> Sunday doIsSessionTimeTest(schedule, true, 2008, Calendar.NOVEMBER, 2, 20, 0, 0, TimeZone.getTimeZone("America/New_York")); //November,7 -> Friday doIsSessionTimeTest(schedule, true, 2008, Calendar.NOVEMBER, 7, 17, 0, 0, TimeZone.getTimeZone("America/New_York")); }*All times below are New York times.
For the sake of the example, our system starts every Sunday at 18:00 while actual trading starts (again every Sunday) at 20:00. Trading ends next Friday at 17:00. So, if you run the test as it is, it passes.
But if you uncomment "mockSystemTimeSource.setTime" the test fails, exactly for the same reason why our system shutdown trading one hour early.
The problem is with the way SessionSchedule converts END_* configuration into actual time point. Sunday November 2nd and Monday November 7th are both EST (winter time), BUT SessionSchedule actually goes back to previous Monday (October 27) which is still EDT (summer time) and thus converts to UTC incorrectly with 1 hour shift.