fix session layer_rev1

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

Upload: panos-stassinopoulos

Post on 14-Jul-2015

325 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fix session layer_rev1

Jump to first page

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Jim NortheyJordan and Jordan

Introduction to FIX

The FIX Session Layer

Page 2: Fix session layer_rev1

Jump to first page

2

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

FIX Session Layer

� Session Level Messages� Login� Message Sequencing� Keeping the session alive – heart beating� Logout

Page 3: Fix session layer_rev1

Jump to first page

3

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 4: Fix session layer_rev1

Jump to first page

4

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 5: Fix session layer_rev1

Jump to first page

5

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 6: Fix session layer_rev1

Jump to first page

6

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 7: Fix session layer_rev1

Jump to first page

7

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 8: Fix session layer_rev1

Jump to first page

8

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Your Application ProgramTrading System, Order Management System

Anatomy of a FIX Engine

TransactionJournal

DBMS

Engine

EncryptionMessage

Store

FIXCounterparty

TCP/IP Connection

Diagram taken from Programmer’s Manual for the .FixAntenna Engine from B2B ITS Consulting Serviceshttp://fix.btobits.com and http://www.btobits.com

Page 9: Fix session layer_rev1

Jump to first page

9

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Customer (i.e. Investment Mgr) Supplier (i.e.Broker/Dealer)

FIX System FIX System

Order Management System

Trader Trader Trader

Trader in Foreign Office

Order Management System

Trader Trader Trader

Trader in Foreign Office

FIX EngineBusiness Msg Processing

Business Msg Processing

FIX Engine Business Msg Processing

Business Msg Processing

Wide Area Network Link

TCP/IP

(TCP Socket opened by customer, persists

during life of FIX session)

FIX System Connectivity

© FIX Protocol Limited - March, 2000

Page 10: Fix session layer_rev1

Jump to first page

10

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Session Level

� Initiating a session (Logon)� Heartbeat� Message Sequencing� Message Validation� Ending a session (Logout)

Page 11: Fix session layer_rev1

Jump to first page

11

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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^

Page 12: Fix session layer_rev1

Jump to first page

12

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Nominal Login Scenario Start of Day

Test Request Initiator

Test Request Recipient

Login MsgType=A, TargetCompID=CBOEFIX001SenderCompID=M001 MsgSeqNum=1

Login MsgType=A, TargetCompID=M001SenderCompID=CBOEFIX001 MsgSeqNum=1

Valid SenderCompIDIncoming Sequence Number

matches expected value

Incoming Sequence Number matches expected value

This is the Logon

Acknowledgement

We have a FIX Session Established!

Page 13: Fix session layer_rev1

Jump to first page

13

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 14: Fix session layer_rev1

Jump to first page

14

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 15: Fix session layer_rev1

Jump to first page

15

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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)

Page 16: Fix session layer_rev1

Jump to first page

16

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Exceptional Login Scenario - Sequence Number to High

Session Initiator

Session Acceptor

Login MsgType=A TargetCompID=CBOEFIX001SenderCompID=M001 MsgSeqNum=3

Login MsgType=A TargetCompID=M001SenderCompID=CBOEFIX001 MsgSeqNum=1

Valid SenderCompIDSequence Number > Expected

Value

Incoming Sequence Number matches expected value

This is the Logon

Acknowledgement

IncomingExpected=1

Resend Request MsgType=2 TargetCompID=M001SenderCompID=CBOEFIX001 MsgSeqNum=2

BeginSeqNo=1 EndSeqNo= 2

Resends messages or sends a gap fill

Page 17: Fix session layer_rev1

Jump to first page

17

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Exceptional Login Scenario - Sequence Number to Low

Session Initiator

Session Acceptor

Login MsgType=A TargetCompID=CBOEFIX001SenderCompID=M001 MsgSeqNum=1

Logout MsgType=5 TargetCompID=M001SenderCompID=CBOEFIX001 MsgSeqNum=1

Text = Incoming Sequence Number <Expected = 5

Valid SenderCompIDSequence Number < Expected

Value

Why do we stop the Session from being

established?

IncomingExpected=5

Disconnect by closing socket

Page 18: Fix session layer_rev1

Jump to first page

18

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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)

Page 19: Fix session layer_rev1

Jump to first page

19

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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^

Page 20: Fix session layer_rev1

Jump to first page

20

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Heartbeating lets each side know the connection is active

Session Initiator

Session Acceptor

Heartbeat MsgType=0 TargetCompID=CBOEFIX001SenderCompID=M001 MsgSeqNum=2

Logout MsgType=5 TargetCompID=CBEOFIX001SenderCompID=M001 MsgSeqNum=1

Login MsgType=A TargetCompID=M001SenderCompID=CBOEFIX001 MsgSeqNum=1

Login MsgType=A TargetCompID=CBOEFIX001SenderCompID=M001 MsgSeqNum=1

Heartbeat MsgType=0 TargetCompID=M001SenderCompID=CBOEFIX001 MsgSeqNum=2

Page 21: Fix session layer_rev1

Jump to first page

21

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

How often do we heartbeat a FIX connection?

� Configurable� “Negotiated” at Logon time

� HeartBtInt (tag 108) Note same value used by both sides

Page 22: Fix session layer_rev1

Jump to first page

22

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 23: Fix session layer_rev1

Jump to first page

23

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Normal Test Request Scenario

Test Request Initiator

Test Request Recipient

Test Request MsgType=1, TestReqID=“AnyString”

Heartbeat MsgType=0, TestReqID=“AnyString”

Page 24: Fix session layer_rev1

Jump to first page

24

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Exception Test Request Scenario

Test Request Initiator

Test Request Recipient

Test Request MsgType=1, TestReqID=“AnyString”

Disconnect by closing socket

Logout MsgType=5 Text=“Test Request Timeout”

No Response from recipient

for 2 X Heartbeat

Interval

Page 25: Fix session layer_rev1

Jump to first page

25

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

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

Page 26: Fix session layer_rev1

Jump to first page

26

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Ending a Session(Logout MsgType=5)

� Each side sends a logout message8=FIX.4.2^9=0082^35=5^49=DFIX201^56=GLTRADE0^34=483^52=20010822-14:05:34^10=176^

Page 27: Fix session layer_rev1

Jump to first page

27

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

Normal Logout Processing

Firm Initiating Logout

Logout Recipient

Logout MsgType=5 TargetCompID=CBOEFIX001SenderCompID=M001 MsgSeqNum=M

Logout MsgType=5 TargetCompID=M001SenderCompID=CBOEFIX001 MsgSeqNum=N

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

Both sides disconnect by closing socket

It is considered bad form to close the

connection prior to receiving the logout

confirmation

Page 28: Fix session layer_rev1

Jump to first page

28

Introduction to FIX Copyright© 2004 Jim Northey and Jordan & Jordan

End of FIX Session LayerSlide Show