Introduction to FIX The FIX Session Layer Jim

  • Slides: 28
Download presentation
Introduction to FIX The FIX Session Layer Jim Northey Jordan and Jordan Introduction to

Introduction to FIX The FIX Session Layer Jim Northey Jordan and Jordan Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

2 FIX Session Layer n n n Session Level Messages Login Message Sequencing Keeping

2 FIX Session Layer n n n Session Level Messages Login Message Sequencing Keeping the session alive – heart beating Logout Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

3 Protocol Overview n n n Standardized session layer using administrative messages Application layer

3 Protocol Overview n n n Standardized session layer using administrative messages Application layer with application messages Messages use tag level encoding u u Tag# “=“ Value <SOH>, ASCII 01 field separator Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

4 Message Structure n All FIX Messages are identified by a Msg. Type[Tag 35]

4 Message Structure n All FIX Messages are identified by a Msg. Type[Tag 35] code u n n (Look up using Volume 6 or using FIXImate for the list of messages) All messages use a standard header and standard trailer Messages consists of required tags and optional tags Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

5 Customization n n Trading parties agree on specific usage and content of fields

5 Customization n n Trading parties agree on specific usage and content of fields subject to the guidelines and definitions provided in the specification FIX provides for custom tags to support extensions or specific trading requirements Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

6 Standard Header n Begin. String[8] identifies the version of FIX being used, for

6 Standard Header n Begin. String[8] identifies the version of FIX being used, for instance: u n n “FIX 4. 1”, “FIX 4. 2” Body. Length[9] identifies the length of the message Msg. Type[35] Message type Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

7 Identification of Trading Parties n n n Sender. Comp. ID[49] - Identifies the

7 Identification of Trading Parties n n n Sender. Comp. ID[49] - Identifies the sender of the message counterparties agree on format Target. Comp. ID[56] - Identifies the recipient of the message counterparties agree on format Additional header fields u u Sub. ID Fields Loc. ID Fields On. Behalf. Of Deliver. To Routing Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

8 Anatomy of a FIX Engine Your Application Program Trading System, Order Management System

8 Anatomy of a FIX Engine Your Application Program Trading System, Order Management System TCP/IP Connection Engine Transaction Journal Encryption FIX Counterparty Message Store DBMS Diagram taken from Programmer’s Manual for the. Fix. Antenna Engine from B 2 B ITS Consulting Services http: //fix. btobits. com and http: //www. btobits. com Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

9 FIX System Connectivity Customer (i. e. Investment Mgr) Supplier (i. e. Broker/Dealer) FIX

9 FIX System Connectivity Customer (i. e. Investment Mgr) Supplier (i. e. Broker/Dealer) FIX System Wide Area Network Link Business Msg Processing FIX Engine Order Management System Trader Business Msg Processing TCP/IP (TCP Socket opened by customer, persists during life of FIX session) Business Msg Processing FIX Engine Business Msg Processing Order Management System Trader in Foreign Office © FIX Protocol Limited - March, 2000 Trader in Foreign Office Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

10 Session Level n n n Initiating a session (Logon) Heartbeat Message Sequencing Message

10 Session Level n n n Initiating a session (Logon) Heartbeat Message Sequencing Message Validation Ending a session (Logout) Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

11 Initiating a Session (Logon Msg. Type=A) n Buy side firm initiates (the Initiator)

11 Initiating a Session (Logon Msg. Type=A) n Buy side firm initiates (the Initiator) a connection to a Sell side (the Acceptor) firm using the LOGON Session Level Message Msg. Type[35]=“A” 8=FIX. 4. 2^ 9=92^ 35=A^ 49=BOFASEC 0^ 56=DFIX 201^ 50=MSO: MSO^ 57=TEST^ 34=106^ 43=N^ 52=20010822 -13: 06: 42^ 98=0^ 108=30^ 10=021^ Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

12 Nominal Login Scenario Start of Day Login Msg. Type=A, Target. Comp. ID=CBOEFIX 001

12 Nominal Login Scenario Start of Day Login Msg. Type=A, Target. Comp. ID=CBOEFIX 001 Sender. Comp. ID=M 001 Msg. Seq. Num=1 This is the Logon Acknowledgement Valid Sender. Comp. ID Incoming Sequence Number matches expected value Test Request Initiator Login Msg. Type=A, Target. Comp. ID=M 001 Sender. Comp. ID=CBOEFIX 001 Msg. Seq. Num=1 Test Request Recipient Incoming Sequence Number matches expected value We have a FIX Session Established! Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

13 Message Sequencing n n n The FIX Session guarantees that messages are delivered

13 Message Sequencing n n n The FIX Session guarantees that messages are delivered in the order in which they are sent A FIX Session can be defined as “a bi-directional stream of ordered messages between two parties within a continuous sequence number series” Each FIX Engines is expected to keep track of two sequence numbers u u The Incoming Sequence Number expected on inbound messages received from the counterparty The Outgoing Sequence Number to be sent to the counterparty Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

14 Message Sequencing n n So what happens if the sequence numbers are not

14 Message Sequencing n n So what happens if the sequence numbers are not in order? FIX Provides messages for recovery of lost messages u u Provides for delivery of lost messages Provides for a way to resynchronize sequence numbers between engines Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

15 Resend Request (Msg. Type=2) n n Used to request the counterparty to resend

15 Resend Request (Msg. Type=2) n n Used to request the counterparty to resend a set of FIX messages Tell the counterparty the range of messages that you did not receive u u Begin. Seq. No (tag 7) End. Seq. No (tag 16) Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

16 Exceptional Login Scenario - Sequence Number to High Login Msg. Type=A Target. Comp.

16 Exceptional Login Scenario - Sequence Number to High Login Msg. Type=A Target. Comp. ID=CBOEFIX 001 Sender. Comp. ID=M 001 Msg. Seq. Num=3 Valid Sender. Comp. ID Sequence Number > Expected Value This is the Logon Acknowledgement Session Initiator Login Msg. Type=A Target. Comp. ID=M 001 Sender. Comp. ID=CBOEFIX 001 Msg. Seq. Num=1 Incoming Expected=1 Session Acceptor Incoming Sequence Number matches expected value Resend Request Msg. Type=2 Target. Comp. ID=M 001 Sender. Comp. ID=CBOEFIX 001 Msg. Seq. Num=2 Begin. Seq. No=1 End. Seq. No= 2 Resends messages or sends a gap fill Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

17 Exceptional Login Scenario - Sequence Number to Low Login Msg. Type=A Target. Comp.

17 Exceptional Login Scenario - Sequence Number to Low Login Msg. Type=A Target. Comp. ID=CBOEFIX 001 Sender. Comp. ID=M 001 Msg. Seq. Num=1 Valid Sender. Comp. ID Sequence Number < Expected Value Why do we stop the Session from being established? Session Initiator Logout Msg. Type=5 Target. Comp. ID=M 001 Sender. Comp. ID=CBOEFIX 001 Msg. Seq. Num=1 Text = Incoming Sequence Number < Expected = 5 Incoming Expected=5 Session Acceptor Disconnect by closing socket Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

18 Sequence Reset (Msg. Type=4) n n In order to reduce unnecessary communication, FIX

18 Sequence Reset (Msg. Type=4) n n In order to reduce unnecessary communication, FIX permits firms to skip or gap fill over administrative messages (such as heartbeats and test requests) This is done using the Sequence Reset Message u u Gap. Fill. Flag (tag 123) New. Seq. No (tag 36) Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

19 Heartbeat (Msg. Type=0) n The FIX Session is kept alive by both sides

19 Heartbeat (Msg. Type=0) n The FIX Session is kept alive by both sides sending heartbeats to the other 8=FIX. 4. 2^ 9=0072^ 35=0^ 49=GLTRADE 1^ 56=DFIX 201^ 34=2^ 52=20010822 -13: 53: 28^ 10=124^ Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

20 Heartbeating lets each side know the connection is active Login Msg. Type=A Target.

20 Heartbeating lets each side know the connection is active Login Msg. Type=A Target. Comp. ID=CBOEFIX 001 Sender. Comp. ID=M 001 Msg. Seq. Num=1 Login Msg. Type=A Target. Comp. ID=M 001 Sender. Comp. ID=CBOEFIX 001 Msg. Seq. Num=1 Heartbeat Msg. Type=0 Target. Comp. ID=CBOEFIX 001 Sender. Comp. ID=M 001 Msg. Seq. Num=2 Session Initiator Heartbeat Msg. Type=0 Target. Comp. ID=M 001 Sender. Comp. ID=CBOEFIX 001 Msg. Seq. Num=2 Session Acceptor … Logout Msg. Type=5 Target. Comp. ID=CBEOFIX 001 Sender. Comp. ID=M 001 Msg. Seq. Num=1 Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

21 How often do we heartbeat a FIX connection? n n Configurable “Negotiated” at

21 How often do we heartbeat a FIX connection? n n Configurable “Negotiated” at Logon time u Heart. Bt. Int (tag 108) Note same value used by both sides Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

22 Test Request (Msg. Type=1) n n Either party on the FIX connection can

22 Test Request (Msg. Type=1) n n Either party on the FIX connection can send a Test Request message at any time during the FIX Session The recipient of a Test Request message must respond with a Heartbeat message The Test Request contains a required Test. Req. ID[112] field The Heartbeat response message must contain the Test. Req. ID[112] of the Test Request Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

23 Normal Test Request Scenario Test Request Initiator Test Request Msg. Type=1, Test. Req.

23 Normal Test Request Scenario Test Request Initiator Test Request Msg. Type=1, Test. Req. ID=“Any. String” Heartbeat Msg. Type=0, Test. Req. ID=“Any. String” Test Request Recipient Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

24 Exception Test Request Scenario Test Request Msg. Type=1, Test. Req. ID=“Any. String” No

24 Exception Test Request Scenario Test Request Msg. Type=1, Test. Req. ID=“Any. String” No Response from recipient for 2 X Heartbeat Interval Test Request Initiator Test Request Recipient Logout Msg. Type=5 Text=“Test Request Timeout” Disconnect by closing socket Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

25 Message Validation n n FIX Engines validate that messages are properly formed and

25 Message Validation n n FIX Engines validate that messages are properly formed and will reject the message using a Session Level REJECT message if the message is invalid The Checksum (tag 10) is validated Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

26 Ending a Session(Logout Msg. Type=5) n Each side sends a logout message 8=FIX.

26 Ending a Session(Logout Msg. Type=5) n Each side sends a logout message 8=FIX. 4. 2^ 9=0082^ 35=5^ 49=DFIX 201^ 56=GLTRADE 0^ 34=483^ 52=20010822 -14: 05: 34^ 10=176^ Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

27 Normal Logout Processing Logout Msg. Type=5 Target. Comp. ID=CBOEFIX 001 Sender. Comp. ID=M

27 Normal Logout Processing Logout Msg. Type=5 Target. Comp. ID=CBOEFIX 001 Sender. Comp. ID=M 001 Msg. Seq. Num=M It is considered bad form to close the connection prior to receiving the logout confirmation Firm Initiating Logout Wait a brief period of time (heartbeat interval) for other side to send logout – this is done in case other side needs to do resend processing Logout Recipient Logout Msg. Type=5 Target. Comp. ID=M 001 Sender. Comp. ID=CBOEFIX 001 Msg. Seq. Num=N Both sides disconnect by closing socket Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page

28 End of FIX Session Layer Slide Show Introduction to FIX Copyright© 2004 Jim

28 End of FIX Session Layer Slide Show Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan Jump to first page