FIX internal sequence numbers

capser picture capser · Aug 12, 2013 · Viewed 7.2k times · Source

I have a process between the Sell side client and an exchange that does currency conversons. There are two FIX adapters - one recieving the messages from the sell side and serving the messages to the process. And another FIX engine that takes the messages from the process and sends them in FIX to the exchange.

Every FIX message has a unique sequence number dented by tag 34. However, it seems that each of these FIX engines has a INCOMING SEQUENCE number (what FIX engine is expecting for counter party) and an OUTGOING SEQUENCE NUMBER (what FIX engine is sending to counter party).

Are these internal sequence numbers independent of tag 34?

In this configuration the Sell side FIX ENGINE's internal sequence numbers are reset to 1,1 upon login. The internal sequence numbers of the FIX ENGINE to the exchange are not reset to 1,1.

I am guessing that this is because there might be GTC orders resting at the exchange and the two engines might 'sink up' on these resting orders upon a successful logon.

However I don't understand the relation between tag 34 and the internal sequence numbers.

Answer

Grant Birchmeier picture Grant Birchmeier · Aug 12, 2013

Any FIX application must maintain two sets of sequence numbers per session: the incoming and the outgoing. These sequence numbers are independent of each other.

  • Every time the app sends a message, it increments the outgoing sequence number and sets it in tag 34.
  • Every time the app receives a message, it increments the expected incoming number and makes sure the incoming message's tag 34 matches it.

If you have two FIX sessions, then each session is tracking a pair of sequences.

Often a provider will want to maintain sequence numbers between disconnects. This is especially important for order management connections, where, for example, you definitely want to know of any order fills that you missed if your connection went down for some reason.

This is not so important for market data feeds. If your connection went down for a minute, you don't care what the price was while you were down -- you only need to know the latest price now. Therefore, the sequence resets on logon.

However I don't understand the relation between tag 34 and the internal sequence numbers.

This question sounds engine-specific. You haven't specified what engine you're using.

But it shouldn't matter much. Every message you send should increment 34; the internal storage is used for this. Every message you receive should have 34 be 1 higher than the last; again, the internal storage is maintained so the app can track this.

If you're using any of the QuickFIX engines, then you shouldn't have to worry about this. QF handles all this for you. (If you think you need to mess with the sequence number in QuickFIX, you're probably wrong. It's a common newbie question. Just set your config correctly and the engine will do the rest.)