![]() |
||||||||||||||||||||||||||||||||||||||||||
FIX Session |
||||||||||||||||||||||||||||||||||||||||||
The FIX Protocol specifications define a FIX session as "a bi-directional stream of ordered messages between two parties within a continuous sequence number series." Parties to a single FIX session may use multiple sequential (but not concurrent) physical connections. They can connect and disconnect several times during a single FIX session. The connected parties must agree on when sessions should start and stop. Two layers in a FIX sessionEach FIX session has two layers of activities. ![]() Session Layer:It deals with administrative tasks like:
Application Layer:The Application Layer deals with actual business contents and trade related information exchange and processing. Role of FF.FIX Engine in your applicationThe entire FF.FIX session layer in FF.FIX Engine is completely automatic and needs no programmatic intervention. FF.FIX Engine completely automates the session layer in FIX sessions and lets you concentrate on the core business functions and logic relevant to your organization for inclusion in the application layer. As FIX developer, you can use the FF.FIX Engine APIs to send application messages to your counterparty, register different session events, monitor FIX session states, monitor FIX connection health and interface with external applications like databases and analysis tools. The FF.FIX Engine based session layer guarantees the bidirectional, ordered and reliable message exchange with the counterparty's FIX Engine. It not only handles all basic session layer requirements of a FIX session (mentioned above) but also offers you excellent control of the FIX session behavior and its analysis through several customizable parameters like latency checks, message throttling, message recovery rules, customizable validation levels, Adapter Plug-ins technology, interfacing with message and event analysis tools etc. About the Session LayerThe session layer guarantees the bidirectional, ordered and reliable message delivery. The entire session layer is based on seven messages-Logon, Logout, Heartbeat, TestRequest, ResendRequest, Reject and SequenceReset. These messages and their descriptions are given below.
Besides these messages there is a lot of session level logic that FF.FIX Engine automates for you. It includes customizable message recovery rules, GapFill mechanisms, resetting sequence number at occurrence of important events, latency checks, session scheduling, make provision for counterparty specific requirements without affecting the common application code etc. About the Application LayerThe application layer holds the core business logic and views the session layer as a black box. Since the FIX Protocol deals with all asset classes (stock, futures, derivatives etc.), the application layer messages include messages for order initiation, getting a fill, changing an order, indication of interest, order execution reports, market data publishing and more. The application layer covers all pre-trade, trade and post-trade activities. Since FF.FIX Engine automates the session layer and provides a rich set of APIs for interfacing with existing trading systems, you can easily implement the business logic relevant to your organization and quickly deploy your application to get a leading edge over your competitors. Physical and FIX connectionsPhysical connection: A physical connection means establishing a telecommunication link using a network protocol. The two parties who wish to engage into a FIX session need to physically connect over some suitable telecommunication link using a suitable network protocol that regulates the telecommunication link. This link can be a telephone line, leased line, ISDN, LAN, WAN etc. FIX connection: After establishing a physical connection, the initiating party sends a Logon message. A FIX connection establishes on acceptance of this Logon message. A FIX connection spans over- [1] session initiation (Logon message), [2] message exchange during the session and [3] session termination (normal termination through a Logout message or abnormal termination by closure of the physical connection). Establishing a FIX connectionA FIX session establishes on making a successful FIX connection. The steps in establishing a FIX connection are:
Terminating a FIX connectionThe physical connection is the preliminary requirement for a FIX connection. Accordingly, a FIX connection can terminate normally or abnormally as follows: Normal termination
Abnormal terminationThe FIX connection terminates abnormally due to failures in the physical connection i.e. the telecommunication link. Duration of physical and FIX connectionsThe duration of FIX connection is less than the duration of Physical connection. The physical connection is the preliminary requirement for a FIX connection. A party can exchange messages as long as the physical connection is intact. FIX connection span over the period from Logon to Logout/abnormal termination. InitiatorThe Initiator is the party which establishes a physical connection with the counterparty and initiates the session via transmission of an initial Logon message. If the initial Logon message is unsuccessful, the initiator needs to reconnect. AcceptorThe Acceptor is the party which validates connection requests (Logon messages) from multiple counterparties and sends counter-Logon message as an acknowledgement to the accepted counterparties. The Acceptor always listens at a predefined physical port for incoming connections and messages. Note: FIX connection and FIX sessionA FIX session is a superset of FIX connections. A single FIX session can span over multiple FIX connections because:
The duration of a FIX connection is from Logon to Logout only. However, over a single FIX session, there can be multiple instances of Logon to Logout messages. Concentrate mainly on Body of Application MessagesEach FIX Message, related to session layer as well as application layer, has three blocks- Header, Body and Trailer. The Header and Trailer of each message contain the crucial information for primary validation of messages and performing session layer related tasks. The Body of session layer messages (Admin Messages) also includes the information relevant to session layer logic. Only the Body of application layer messages (Application Messages) includes the information relevant to the trade. FF.FIX Engine enables you to concentrate on the logic for the Body part of Application Messages mainly.
|
||||||||||||||||||||||||||||||||||||||||||
The FixSession class in FF.FIX Engine manages the FIX session between the Initiator and Acceptor applications. The objects of FixSession class are not directly created. These objects are accessible through FF.FIX Engine based Initiator/Acceptor application. FIX session statesThe states of a FIX session are the states of the FixSession object. At a given time it is in one of the following states:
FIX session state change alertsYou may access the FixSession state change by registering to the SessionStateChanged event of FixSession object. See the following code: FixSession fixSession; If(fixSession != null) private void OnSessionStateChanged(FixSession fixSession, eSessionState currentSessionState, eSessionState previousSessionState) Sending Application Messages from FixSession objectOne of the important methods of the FixSession is the SendMessage method, used to send a custom Application Message to the counterparty. For example, FixMessage orderMessage = GetNewOrderMessage(); |
||||||||||||||||||||||||||||||||||||||||||
See the following code: FF.Fix.Core.Session.eSessionState sessionState = fixSession.GetSessionState(); |
||||||||||||||||||||||||||||||||||||||||||
See the following code: string ipAddress = fixSession.ClientIPEndPoint; |
||||||||||||||||||||||||||||||||||||||||||
The objects of FixSession provide many APIs to extract different parameters. For example, //Getting the date and time of session-start. //Getting the heartbeat interval |
||||||||||||||||||||||||||||||||||||||||||
The AlertManager enables your application to listen to alert notifications on different events and changing states of the FixSession object. The following table lists different alert types.
For example, //Register to listen all session alerts private void OnFIXSesssionAlertMessage(SessionInfo fixSessionInfo, eAlertType alertType, string alertMessage, string additionalMessage) { { { { { |
||||||||||||||||||||||||||||||||||||||||||