The Session Scheduler exposes OnixS::FIX::Scheduling::SessionSchedule class to define the interval of time during which session must be logged on (active). It also provides the facility to automatically reset message sequence numbers as is commonly required by trading systems and venues.
The OnixS::FIX::Scheduling::SessionSchedule constructor initializes the session schedule for all supported cases based on the given parameters.
The first two parameters (firstDay
and lastDay
) define activity week. During these days the session will always be connected at logon time and disconnected at logout time if 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.
firstDay
and lastDay
parameters are supported. It is possible for the firstDay
parameter value be greater than value of lastDay
parameter. In such case schedule will cross the end of the week and continue till the lastDay
. If firstDay
and lastDay
parameters are of the same value, then length (number of days) of 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 single day. However, if logonTime
is greater than logoutTime
, then activity week will equal to seven days (first logon will be performed at logon time on 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 session duration is a single day. If the session must continue for the entire week, then logonTime
parameter value specifies the time for logon to be performed on the first day of activity week and logoutTime
parameter value defines the time of logout performed on the last day of the activity week.
logoutTime
parameter is less than logonTime
parameter value, then it is assumed that the activity time crosses midnight. In such 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::SessionDurations::Day then logon and logout occur on the same day (logout may occur on 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).
seqNumberResetPolicy
parameter must conform to the value of sessionDuration parameter. In particular, message sequence numbers cannot be reset on daily basis if logon/logout frequency is one per week.using namespace OnixS::FIX::Scheduling; void constructScheduleVariations() { // Session continues since 8:00 till 17:00 each day of business week. SessionSchedule regularSingleDay( DaysOfWeek::Monday, DaysOfWeek::Friday, TimeOfDay(8, 0), TimeOfDay(17, 0), SessionDurations::Day, SequenceNumberResetPolicies::Never); // Session starts on Monday, at 8:00 and continues till 17:00 of Friday. SessionSchedule regularWeek( DaysOfWeek::Monday, DaysOfWeek::Friday, TimeOfDay(8, 0), TimeOfDay(17, 0), SessionDurations::Week, SequenceNumberResetPolicies::Never); // 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 final logout will occur at 5:00 on Saturday morning. // On next Monday, before the logon, message sequence numbers will be reset. SessionSchedule crossMidnightSingleDay( DaysOfWeek::Monday, DaysOfWeek::Saturday, TimeOfDay(23, 0), TimeOfDay(5, 0), SessionDurations::Day, SequenceNumberResetPolicies::Weekly); // Session starts on Friday at 16:00, continues four // calendar days and is disconnected on Monday, at 02:00. SessionSchedule crossMidnightWeek( DaysOfWeek::Friday, DaysOfWeek::Monday, TimeOfDay(16, 0), TimeOfDay(2, 0), SessionDurations::Week, SequenceNumberResetPolicies::Never); }
The schedule construction is simplified with parameters to satisfy most common use cases. In particular, it exposes only the ability to define logon and logout time equal for all 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 week. Modifying entries of these collections gives the more advanced capability to define different logon/logout time for different days.
The following example demonstrates how a schedule can be updated to make a session be disconnected earlier on Friday compared to other days.
using namespace OnixS::FIX::Scheduling; void constructScheduleWithShortTradingForFriday() { // Initially, constructs schedule with same logon/logout time for all days. SessionSchedule scheduleWithShortFriday( DaysOfWeek::Monday, DaysOfWeek::Friday, TimeOfDay(8, 0), TimeOfDay(17, 0), SessionDurations::Day, SequenceNumberResetPolicies::Never); // Then, updates value of logout event for Friday day. scheduleWithShortFriday.logoutTime( DaysOfWeek::Friday, TimeOfDay(16, 30)); // 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( DaysOfWeek::Monday, DaysOfWeek::Friday, TimeOfDay(8, 0), TimeOfDay(17, 0), SessionDurations::Day, SequenceNumberResetPolicies::Never); // Then, disables logon and logout on Wednesday. scheduleWithWednesdayOff.logonTime( DaysOfWeek::Wednesday, TimeOfDay::bad()); scheduleWithWednesdayOff.logoutTime( DaysOfWeek::Wednesday, TimeOfDay::bad()); // And that's all. }