The sample demonstrates how a FIX Antenna C++ user can connect to the FIX Gateway (venue) and send pre-loaded messages.
The ConnectToGateway sample shows how to use the scheduling functionality described in Scheduler.
The features implemented in the sample:
- Establish a connection with FIX Gateway as FIX initiator and disconnect from it according to the schedule
- Switch to backup connections in case if the primary connection becomes unavailable
- Send a FIX message from the file to the counterparty
- Create a New Order - Single (D) using FIX Antenna API and setting various FIX tags
- Create a session configured in the
- Use of a customized Logon (A) message for passing user credentials
- Customized reaction on Resend Request (2) messages
- Print the received messages on a console
- Reset sequence numbers according to the schedule
The application initializes the Engine and prepares a message for sending. Message content can be prepared from the file configured in the
MsgFile property or via API if the
MsgFile property is not set.
Configuring the sessions
The ConnectToGateway sample covers the following scenarios:
- Sessions are not configured in
In this case, the sample starts the hardcoded session.
- Sessions are configured in
engine.propertieswithout a schedule.
In this case, the sample starts the pre-configured session immediately.
- Sessions are configured in
engine.propertieswith a schedule.
In this case, the sample starts the pre-configured session according to the schedule.
Sequences are reset on
A user can pass a customized logon message via the
A user should inherit a class from
Engine::Application and override the virtual methods.
MyApp class in the ConnectToGateway sample: all important callbacks print the information to the console. On resend request, it asks a user for action in case of resend requests processing.
If the user wants to define scheduled actions before a trading day or after, it is needed to override callbacks inherited from the
MyScheduleManager class in the sample: Sessions Schedule Manager drops sequence numbers, uses the custom logon at onTradePeriodBegin.
Using schedule in user's application
Scheduling functionality is described in the Programmer's Guide (refer to the Scheduler section).
For applying the schedule, a user should initiate sessions from
FAProperties::ConfiguredSessionsMap sessions = FixEngine::singleton()->getProperties()->getConfiguredSessions(INITIATOR_SESSION_ROLE);
The Scheduler calls the function of a schedule. The schedule function prepares the execution plan and provides its execution.
The schedule function interacts with the Session Controller to obtain the list of all sessions which are registered by the Controller.
The schedule receives notifications about
The schedule accepts events in the cron-like format.
If sessions have a schedule, then the user can pass the session schedule to the Controller. The further session state management will be done by the Session Controller according to the session schedule.
pSchedule = Engine::SessionsSchedulePtr(FixEngine::singleton()->getScheduler()->getSchedule(sessionIt->second.schedule_)); // ... sessionsController_ = FixEngineSessionsControllerPtr(pSchedule->getSessionsController());
Session Controller is an owner of one or multiple sessions in the application.
Each session should be registered with the Session Controller. Otherwise, a session cannot be started according to the schedule.
Session Controller provides the uniform interface to start/stop a session, to perform connection/disconnection of a session via ID.
For resetting sequences at the start of trading day, the Session Controller should be passed to user's Scheduler manager.
Sessions Schedule Manager receives notifications about the
TradePeriodEndevent events and gets the execution plan.
Finally, ownership over the session should be granted to the Sessions Controller:
sessionsController_->registerSession(sessionId_, *this, sessionIt->second);