Search code examples
quickfixfix-protocolquickfixn

QuickFixN: How to set fields in a specific sequence on a QuoteRequest message?


We have a requirement to send the first 3 fields of the message in the order that they are set, i.e. QuoteReqID, OnBehalfOfCompID, Account. However when they are added to the message, they get reordered numerically ascending, i.e. Account, OnBehalfOfCompID, QuoteReqID. With the group, we are able to define the field order but I see no option to do this for the message. Does anybody know how we can achieve this?

            var message = new QuoteRequest();
            int[] fieldOrder = new[] {Tags.Currency, Tags.Symbol, Tags.SecurityType, Tags.CFICode, Tags.NoLegs, Tags.LegQty, Tags.LegFutSettDate, Tags.LegSecuritySubType};

            message.SetField(new QuoteReqID(stream.QuoteRequestId));
            message.SetField(new OnBehalfOfCompID(_compId));
            message.SetField(new Account(_accountId));
            var group = new Group(Tags.NoRelatedSym, 0, fieldOrder);
            group.SetField(new Currency(stream.Ccy));
            group.SetField(new Symbol(stream.Ccy1 + "/" + stream.Ccy2));
            group.SetField(new SecurityType("FOR"));
            group.SetField(new CFICode("FORWARD"));
            group.SetField(new NoLegs(1));
            group.SetField(new LegQty(stream.Amount));
            group.SetField(new LegFutSettDate(stream.FutSettDate));
            group.SetField(new LegSecuritySubType("TOD"));

            message.AddGroup(group);

            QuickFix.Session.SendToTarget(message, _ratesSession.SessionId);

Solution

  • This is absolutely not how FIX protocol is specified to behave. In the spec, fields in the Body that are not inside a repeating group can be in any order. Your counterparty is asking for non-FIX-compliant behavior (and I can see no benefit for it).

    As such, QuickFIX/n does not support this, because... QF/n implements FIX, and not this stupid non-FIX behavior that your counterparty wants.

    I'm sorry to tell you this, but you will have to hack the engine somehow to make this happen.

    One more caveat: OnBehalfOfCompID is a header field, not a body field. QF/n should not have a problem with you adding it to an outgoing message's body, but it would likely reject such a message when incoming. (Thanks to @ciaran-mchale 's answer for pointing this out.)