OnixS C++ FIX Engine  4.10.1
API Documentation

Session Scheduler exposes the OnixS::FIX::Scheduling::SessionSchedule class to define the interval of time during which session must be logged on (active). It also provides facility to reset message sequence numbers automatically as it is commonly required by trading systems and venues.

Defining Session Connection Time-frames

The OnixS::FIX::Scheduling::SessionSchedule constructor initializes the session schedule for all supported cases that are based on the given parameters.

The first two parameters (firstDay and lastDay) define the activity week. During these days the session will be always connected at logon time and disconnected at logout time if the specified session duration equals to a single day. If the session must continue for entire week, then the scheduler will connect session at logon time on the day, specified by the firstDay parameter and disconnected at logout time on the day, specified by lastDay parameter.

Note
All combinations of values for firstDay and lastDay parameters are supported. It is possible for the firstDay parameter value to be greater than value of lastDay parameter. In such a case, schedule will cross the end of the week and continue till lastDay. If firstDay and lastDay parameters are of the same value, then length (number of days) of the activity week depends on the values of logonTime and logoutTime parameters. In particular, if logonTime is less than logoutTime, then the activity week will equal to a single day. However, if logonTime is greater than logoutTime, then the activity week will equal to seven days (first logon will be performed at logon time on the first day, last logout will be performed at logout time a week later).

The logonTime and logoutTime parameters respectively define time of logon and logout for the session for each activity day if the session duration is a single day. If the session must continue for the entire week, then the logonTime parameter value specifies the time for logon to be performed on the first day of the activity week and the logoutTime parameter value defines the time of logout, performed on the last day of the activity week.

Note
If session duration specified by sessionDuration parameter is equal to OnixS::FIX::Scheduling::SessionDuration::Day value and value of logoutTime parameter is less than logonTime parameter value, then it is assumed that the activity time crosses midnight. In such a case, the session scheduler will connect session at logon time on one day and disconnect it on the next calendar day.

The sessionDuration parameter defines whether session must continue for the entire activity week (specified by firstDay and lastDay parameters), or the activity time frame is limited to a single day (24 hours). In particular, if the parameter value equals to OnixS::FIX::Scheduling::SessionDuration::Day, then logon and logout occur on the same day (logout may occur on the next day, if value of logoutTime parameter is less than value of logonTime parameter).

Final seqNumberResetPolicy parameter specifies whether the message sequence numbers must be reset and on which basis (daily or weekly).

Note
Value of seqNumberResetPolicy parameter must conform to the value of sessionDuration parameter. In particular, message sequence numbers cannot be reset on a daily basis if logon/logout frequency is one per week.

By default, the Scheduler uses the local time to determine when a session should be connected/disconnected in accordance with the Schedule. In this case, for different time zones, there is a need to create/configure different schedules. However, you can use OnixS::FIX::Scheduling::SessionScheduler::utcTimeUsage option for switching local time to UTC time usage. In this case, the Scheduler will use the UTC time and you can create/configure the one schedule using the UTC time for all time zones. This can be useful when you deploy your application in different time zones and you need the same behavior of the Scheduler in all time zones by creating only one schedule.

Example

using namespace OnixS::FIX::Scheduling;
void constructScheduleVariations()
{
// Session continues since 8:00 till 17:00 each day of a business week.
SessionSchedule regularSingleDay(
TimeOfDay(8, 0), TimeOfDay(17, 0),
// Session starts on Monday, at 8:00 and continues till 17:00 of Friday.
SessionSchedule regularWeek(
TimeOfDay(8, 0), TimeOfDay(17, 0),
// Session starts on Monday at 23:00, crosses midnight and is disconnected
// at 05:00 on Tuesday. Next connection is established on Tuesday, at 23:00
// and interrupted at 05:00 on Wednesday. And so on. Last logon will be performed
// on Friday, at 23:00 and the final logout will occur at 5:00 on Saturday morning.
// The next Monday, before the logon, message sequence numbers will be reset.
SessionSchedule crossMidnightSingleDay(
TimeOfDay(23, 0), TimeOfDay(5, 0),
// Session starts on Friday at 16:00, continues four
// calendar days and is disconnected on Monday, at 02:00.
SessionSchedule crossMidnightWeek(
TimeOfDay(16, 0), TimeOfDay(2, 0),
}

Advanced Cases

The schedule construction is simplified with parameters to satisfy the most common use cases. In particular, it exposes only the ability to define logon and logout time equal for all the activity days. However, sometimes it is necessary to define different logon and logout times for different days. OnixS::FIX::Scheduling::SessionSchedule provides this ability through the OnixS::FIX::Scheduling::SessionSchedule::logonTime and OnixS::FIX::Scheduling::SessionSchedule::logoutTime members.

Both OnixS::FIX::Scheduling::SessionSchedule::logonTime and OnixS::FIX::Scheduling::SessionSchedule::logoutTime members return and update logon and logout time appropriately for a given day of the week. Modifying entries of these collections give the more advanced capability to define different logon/logout time for different days.

Example

The following example demonstrates how a schedule can be updated to make a session to be disconnected earlier on Friday, compared to other days.

using namespace OnixS::FIX::Scheduling;
void constructScheduleWithShortTradingForFriday()
{
// Initially, constructs schedule with the same logon/logout time for all days.
SessionSchedule scheduleWithShortFriday(
TimeOfDay(8, 0),
TimeOfDay(17, 0),
// Then, updates value of logout event for Friday day.
scheduleWithShortFriday.logoutTime(
// And that's all.
}

Another example demonstrates how schedule can be updated to define one day off in the middle of the trading week.

using namespace OnixS::FIX::Scheduling;
void constructScheduleWithWednesdayAsOffDay()
{
// Initially, constructs schedule with same logon/logout time for all days.
SessionSchedule scheduleWithWednesdayOff(
TimeOfDay(8, 0),
TimeOfDay(17, 0),
// Then, disables logon and logout on Wednesday.
scheduleWithWednesdayOff.logonTime(
scheduleWithWednesdayOff.logoutTime(
// And that's all.
}