Managing FIX Sequence Numbers During Reconnection
Summary
The document explains how a QuickFIX/n application can manage FIX 4.2 message sequence numbers when reconnecting to a broker. The use case is to lower the stored expected inbound sequence number after disconnecting so that the application can request resent messages and receive gap fills. The accepted response identifies QuickFIX/n session methods for setting the next target and sender sequence numbers, which were added in later builds and can be used to adjust sequence state.
A second answer cautions that brokers generally do not roll sequence numbers backward mid-session, questioning how often the scenario occurs in practice. The discussion distinguishes changing stored sequence numbers through the session API from reset flags, which the questioner had found unsuitable. It offers implementation guidance but no protocol walkthrough, tested code, or evidence about broker-specific behavior; applications still need to account for their counterparty’s policies and FIX session rules.
Key ideas
- QuickFIX/n provides session methods for setting the next target and sender message sequence numbers.
- Adjusting the target sequence number can support recovery when the broker’s incoming sequence is lower than expected.
- Reset flags are not presented as the appropriate mechanism for this particular sequence adjustment.
- The response cautions that brokers usually do not move sequence numbers backward during an active session.
Tags
Full text
# Resequencing of MsgSeqNum in FIX 4.2 # Resequencing of MsgSeqNum in FIX 4.2 I am trying to achieve the following functionality using QuickFIX for FIX 4.2 - Send a couple of orders and make sure they’re filled. - Then disconnect. - Change the incoming (from Broker) sequence number to a lower number. Example if it is 300 i now change it to 260. - Log back in. - My Application should detect the sequence number from Broker, as lower than what is expected and my side should automatically send a type 2 (resend request) message to Broker. - Broker will gap fill/send missing data. At the moment when i attempt the step 3 (i.e change to sequence number from broker to a lower value) and then attempt to login, my applications logs out immediately with the error message the MsgSeqNum is lower than what is expected. I am familiar with the ResetSequenceNumFlag, ResetOnLogon, ResetOnLogout flags but they don't seem to be the right choice for the above procedure. ## Answer by Taimoor Choudhary (score 2, accepted) https://quant.stackexchange.com/a/7141 I am using QuickFIX/n, initially there were no methods to change the sequence number but we requested the QuickFIX/n developer community for adding methods to change the sequence numbers and in the later builds Session.NextTargetMsgSeqNum and Session.NextSenderMsgSeqNum were added to change the sequence number. And i was able to easily change the sequence numbers according to my requirements using the methods Session.NextTargetMsgSeqNum and Session.NextSenderMsgSeqNum. ## Answer by Andy Malakov (score 3) https://quant.stackexchange.com/a/3435 Are you sure there is a practical use case behind this (especially step #3). Brokers don't switch sequence number back in the middle of the session. If you absolutely need to support this use Sesssion.setNextTargetMsgSeqNum() API
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.