FIX Session Initiator
Creating FIX session initiator
Refer to the section FIX Session to read about sessions-initiators. To create session-initiator follow the 2-steps instruction below:
Call any of
After the session is created, use one of the parametrized
V12.FIXAntenna.Session.connect()methods to start session as initiator (session will immediately try to establish connection with counterparty i.e. establish telecommunication link, send FIX Logon message and wait for confirming FIX Logon message from counterparty).
import V12.FIXAntenna as v12 try: engine = v12.FixEngine() ssn = engine.create_session(v12.SessionId("TEST1", "TEST2"), "FIX44", v12.FIXVersion.FIX44) ssn.connect(30, "127.0.0.1", 8901) while True: s = input("input: 'q' to exit\n") if s == "q": break except (Exception) as e: print(e)
V12.FIXAntenna.Session.connect() is called the initiator attempts to establish a FIX session in the background. The following scenario is executed:
Establishing the telecommunication link (TCP/IP)
Sending FIX Logon message
Waiting for a Confirm logon message
Moving to the “Established” state There is no need to wait until the connection is established to send messages. If the connection is not established messages will be sent later, after the connection process succeeds (for more information refer to Late delivery vs rejecting).
The initiator is responsible for restoring connection once it is broken. When connection error is detected the initiator moves to the “Reconnect” state and starts a reconnection process. The following scenario is executed:
Establish telecommunication link
Send Logon message
Repeat from 1 if 1 or 2 fails
Stop trying if the number of attempts exceeds limit specified in configuration
The number of reconnection attempts and delay can be set in the properties file (see Reconnect.MaxTries and Reconnect.Interval). Refer to Configuration for more details.
You can use the following methods to close connection (the process can also be called “terminate”, “delete”, “disconnect”):
The session will not be marked as correctly terminated and persistent information about it will be used during the subsequent connections. The
V12.FIXAntenna.Session.reset_seq_num_local() may be used to reset session’s sequence numbers if required.
V12.FIXAntenna.Session.finalize() method to release the allocated resources.
It is vital to call the
V12.FIXAntenna.Session.finalize() method only once for the given session.
To send application-level messages, use the
V12.FIXAntenna.Session.put() method. There is no need to send session level messages (e.g. heartbeats), all session level messages are sent automatically when needed by the engine.