More Related Content
Similar to Fix session layer_rev1 (20)
Fix session layer_rev1
- 1. 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. 2
FIX Session Layer
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. 3
Protocol Overview
Standardized session layer using administrative messages
Application layer with application messages
Messages use tag level encoding
Tag#
“=“
Value
<SOH>, ASCII 01 field separator
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 4. 4
Message Structure
All FIX Messages are identified by a MsgType[Tag 35] code
(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. 5
Customization
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. 6
Standard Header
BeginString[8] identifies the version of FIX being used, for
instance:
“FIX 4.1”, “FIX 4.2”
BodyLength[9] identifies the length of the message
MsgType[35] Message type
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 7. 7
Identification of Trading Parties
SenderCompID[49] - Identifies the sender of the message -
counterparties agree on format
TargetCompID[56] - Identifies the recipient of the message -
counterparties agree on format
Additional header fields
SubID Fields
LocID Fields
OnBehalfOf
DeliverTo
Routing
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 8. 8
Anatomy of a FIX Engine
Your Application Program
Trading System, Order Management System
TCP/IP Connection FIX
Counterparty
Engine
Transaction Message
Journal Encryption
Store
DBMS
Diagram taken from Programmer’s Manual for the .FixAntenna Engine from B2B 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. 9
FIX System Connectivity
Customer (i.e. Investment Mgr) Supplier (i.e.Broker/Dealer)
FIX System FIX System
Wide Area Network Link
Business Msg FIX Engine FIX Engine Business Msg
Processing TCP/IP Processing
(TCP Socket opened by
Business Msg customer, persists Business Msg
Processing during life of FIX session) Processing
Order Management System Order Management System
Trader Trader Trader Trader Trader Trader
Trader in
Foreign Trader in
Office Foreign
© FIX Protocol Limited - March, 2000 Office
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 10. 10
Session Level
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. 11
Initiating a Session (Logon MsgType=A)
Buy side firm initiates (the Initiator) a connection to a Sell side
(the Acceptor) firm using the LOGON Session Level Message
MsgType[35]=“A”
8=FIX.4.2^
9=92^
35=A^
49=BOFASEC0^
56=DFIX201^
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. 12
Nominal Login Scenario Start of Day
Login MsgType=A, TargetCompID=CBOEFIX001
SenderCompID=M001 MsgSeqNum=1
Valid SenderCompID
Incoming Sequence Number
This is the matches expected value
Logon
Acknowledgement Test Test
Request Login MsgType=A, TargetCompID=M001 Request
Initiator SenderCompID=CBOEFIX001 MsgSeqNum=1 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. 13
Message Sequencing
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
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. 14
Message Sequencing
So what happens if the sequence numbers are not in order?
FIX Provides messages for recovery of lost messages
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. 15
Resend Request (MsgType=2)
Used to request the counterparty to resend a set of FIX
messages
Tell the counterparty the range of messages that you did not
receive
BeginSeqNo (tag 7)
EndSeqNo (tag 16)
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 16. 16
Exceptional Login Scenario - Sequence Number to High
Login MsgType=A TargetCompID=CBOEFIX001
SenderCompID=M001 MsgSeqNum=3
Valid SenderCompID Incoming
Sequence Number > Expected Expected=1
Value
This is the
Logon Session Session
Login MsgType=A TargetCompID=M001
Acknowledgement Initiator Acceptor
SenderCompID=CBOEFIX001 MsgSeqNum=1
Incoming Sequence Number
matches expected value
Resend Request MsgType=2 TargetCompID=M001
SenderCompID=CBOEFIX001 MsgSeqNum=2
BeginSeqNo=1 EndSeqNo= 2
Resends messages or sends a gap fill
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 17. 17
Exceptional Login Scenario - Sequence Number to Low
Login MsgType=A TargetCompID=CBOEFIX001
SenderCompID=M001 MsgSeqNum=1
Valid SenderCompID Incoming
Sequence Number < Expected Expected=5
Value
Why do we stop the
Session from being Session Session
Logout MsgType=5 TargetCompID=M001
established? Initiator Acceptor
SenderCompID=CBOEFIX001 MsgSeqNum=1
Text = Incoming Sequence Number <
Expected = 5
Disconnect by closing socket
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 18. 18
Sequence Reset (MsgType=4)
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
GapFillFlag (tag 123)
NewSeqNo (tag 36)
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 19. 19
Heartbeat (MsgType=0)
The FIX Session is kept alive by both sides sending heartbeats to
the other
8=FIX.4.2^
9=0072^
35=0^
49=GLTRADE1^
56=DFIX201^
34=2^
52=20010822-13:53:28^
10=124^
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 20. 20
Heartbeating lets each side know the connection is active
Login MsgType=A TargetCompID=CBOEFIX001
SenderCompID=M001 MsgSeqNum=1
Login MsgType=A TargetCompID=M001
SenderCompID=CBOEFIX001 MsgSeqNum=1
Heartbeat MsgType=0 TargetCompID=CBOEFIX001
SenderCompID=M001 MsgSeqNum=2
Session Session
Initiator Acceptor
Heartbeat MsgType=0 TargetCompID=M001
SenderCompID=CBOEFIX001 MsgSeqNum=2
…
Logout MsgType=5 TargetCompID=CBEOFIX001
SenderCompID=M001 MsgSeqNum=1
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 21. 21
How often do we heartbeat a FIX connection?
Configurable
“Negotiated” at Logon time
HeartBtInt (tag 108) Note same value used by both sides
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 22. 22
Test Request (MsgType=1)
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 TestReqID[112] field
The Heartbeat response message must contain the
TestReqID[112] of the Test Request
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 23. 23
Normal Test Request Scenario
Test Request MsgType=1, TestReqID=“AnyString”
Test
Test
Request
Request
Initiator
Heartbeat MsgType=0, TestReqID=“AnyString” Recipient
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 24. 24
Exception Test Request Scenario
Test Request MsgType=1, TestReqID=“AnyString”
No Response
from recipient
Test for 2 X Test
Request Heartbeat Request
Initiator Interval Recipient
Logout MsgType=5 Text=“Test Request Timeout”
Disconnect by closing socket
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 25. 25
Message Validation
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. 26
Ending a Session(Logout MsgType=5)
Each side sends a logout message
8=FIX.4.2^
9=0082^
35=5^
49=DFIX201^
56=GLTRADE0^
34=483^
52=20010822-14:05:34^
10=176^
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 27. 27
Normal Logout Processing
Logout MsgType=5 TargetCompID=CBOEFIX001
It is considered bad SenderCompID=M001 MsgSeqNum=M
form to close the
connection prior to
receiving the logout Wait a brief period of time
confirmation (heartbeat interval) for other side
to send logout – this is done in
case other side needs to do
Firm resend processing Logout
Initiating
Recipient
Logout
Logout MsgType=5 TargetCompID=M001
SenderCompID=CBOEFIX001 MsgSeqNum=N
Both sides disconnect by closing socket
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page
- 28. 28
End of FIX Session Layer
Slide Show
Introduction to FIX
Copyright© 2004 Jim Northey and Jordan & Jordan
Jump to first page