MsgSeqNum generation

Imported from previous forum

[ original email was from Ranjit M - ranjit_unni@yahoo.com ]
Hi,
I am looking at building a FIX Gateway(gateway to a trading system talking native API/FIX). Obviously, the heart of the gateway is going to be the session protocol implementation. But, the specification was not helpful in answering these questions.

For a FIX Gateway Application:
a. How appropriate is it to have the Trading System generate the MsgSeqNum instead of the gateway?

b. Will MsgSeqNum generation/validation done at the business layer deviate from FIX session protocol specification?

c. Assuming the above scenario, would the dependency of the FIX Gateway on the Trading system for basic session-level handling of a FIX message be non-conformant?

d. Can it be asserted that MsgSeqNum generation/validation is an integral part of the Session protocol and cannot be part of the Trading System, since there is no existence for the gateway without the trading system?

Any suggestions/comments would be helpful.

Thanks in advance,
Ranjit

Ranjit:
> a. How appropriate is it to have the Trading
> System generate the MsgSeqNum instead of the
> gateway?

In any layered communications protocol it is generall considered y a Bad Idea to mix layer functionality and implementations. Think of the session layer as part of your transport stack; The trading system should live exclusively at the higher-level application layer, and hand off communications details to the stack below it.

If you don’t mind reading a good book (:-), take a look at “Computer Networks” by A. Tannenbaum (Prentice Hall, ISBN: 0133499456). The rationale behind layered protocol implementations is very well explained in the first chapters.

> b. Will MsgSeqNum generation/validation done at
> the business layer deviate from FIX session
> protocol specification?
> c. Assuming the above scenario, would […]
> d. Can it be asserted that MsgSeqNum […]

There’s nothing in the standard that says where the sequences should be generated. As long as your box talks “correct” FIX session stuff to the counterparty box, you could have FIX-conformant gerbils typing in the numbers :-).

Just think of separating app and session implementations as good modular programming. Believe me, the heirs to your code will be grateful for it.

MZ

Here are my answers to your questions:
a) It is not advised to have your application level generate the MsgSeqNum used in the session level. Each FIX session that you establish from your FIX engine must maintain its own MsgSeqNum counters. This is to provide integrety to each of the session and allow you to recover any missed messages for that session. Your application would be generating application level seq nums, such as the ClOrdID’s (if you’re a buy-side) or the OrderID’s (if you’re a sell-side).

b) and c) Yes, from my 7 yrs experience of implementing and testing FIX connections I’ve never come across anyone who implemented it the way you intend to. See a).

d) Yes. The FIX engine is the generator and validator of the session level MsgSqNum. Separation of the session level from the application level is a better design in the long run, in terms of flexibility and maintainability of your FIX engine.

Have you thought about evaluating any of the FIX engine vendors out there? It may make better sense than to build your own, in particular since most of them will provide you with a solid session level handling already.

> Hi,
> I am looking at building a FIX Gateway(gateway to a trading system talking native API/FIX). Obviously, the heart of the gateway is going to be the session protocol implementation. But, the specification was not helpful in answering these questions.
>
> For a FIX Gateway Application:
> a. How appropriate is it to have the Trading System generate the MsgSeqNum instead of the gateway?
>
> b. Will MsgSeqNum generation/validation done at the business layer deviate from FIX session protocol specification?
>
> c. Assuming the above scenario, would the dependency of the FIX Gateway on the Trading system for basic session-level handling of a FIX message be non-conformant?
>
> d. Can it be asserted that MsgSeqNum generation/validation is an integral part of the Session protocol and cannot be part of the Trading System, since there is no existence for the gateway without the trading system?
>
> Any suggestions/comments would be helpful.
>
> Thanks in advance,
> Ranjit
>