6

I use a QuickFix/n initiator. My broker rejects my logon messages, citing wrong order of fields (tags) in the message header. Instead of 34, 49, 52, 56, the order should be 49, 56, 34, 52.

QuickFix/n seems to automatically sort the various fields within the three regions (header, body, trailer) of messages by tag number upon sending the message to the session.

Is there a way to change the order of the fields in a message sent to an acceptor? Is there a way to prevent the sorting behaviour? (Adding groups to the message or changing the data dictionary don't work.)

Or if that is impossible with QuickFix/n, is there a FIX engine which allows changing the order of fields in messages?

user3723746
  • 61
  • 1
  • 2
  • 1
    I am sure you're misunderstanding something. In FIX protocol, order of fields doesn't matter except within repeating groups. All of these fields are in the header, so the order does not matter within the header (except 8,9,35 which must come first). **What is the actual error message they are sending back?** – Grant Birchmeier Jun 10 '14 at 01:04
  • Yes Grant, but you have to add them to the correct group (header, body or trailer) otherwise you get this error! – MD-Tech Jun 10 '14 at 08:03
  • @GrantBirchmeier Can you point me to where in the FIX 4.4 standard it states that repeating groups must have a fixed order? I have a vendor sending in random order and it sometimes causes QuickFix to fail to parse the message correctly. – Jonathan Feb 15 '22 at 17:50
  • @Jonathan in Vol 1, in the section `FIX "Tag=Value" SYNTAX", item 4 in the numberd list: "Fields within repeating data groups must be specified in the order that the fields are specified in the message definition within the FIX specification document. The NoXXX field where XXX is the field being counted specifies the number of repeating group instances that must immediately precede the repeating group contents." – Grant Birchmeier Feb 15 '22 at 18:53
  • @GrantBirchmeier thank you, I was able to find it now. – Jonathan Feb 15 '22 at 20:21

4 Answers4

5

This error is normally caused by trying to put a header field into the body of the message. The DataDictionary object provided either by yourself if you are manually adding it to the session or from the session itself (if you are using the config file to tell the session which data dictionary to use) has functions called isHeaderField(int tagNumber) and isTrailerField(int tagNumber) to help you decide if the field should be in the header or the trailer. Different data dictionary files for different counterparties may (I've only seen it once or twice) put header fields into the body part of the message, body fields into the header, or (most commonly) custom tags into the header. This means that it is generally a good idea to use the available functions to check whether a field should be added to the header, body, trailer or a repeating group within the body. Since this question is about logon messages I am guessing that you are adding fields to that message type so I may need to see the code doing that to help further.

MD-Tech
  • 1,224
  • 1
  • 9
  • 15
  • Hi @MD-Tech, I've found your answers useful over the past few months developing our in-house trading platform. We're look for a code-review/consult, if you're interested please reply here and we can figure out a way to connect! – Mir May 15 '21 at 16:04
  • @Mir unfortunately I've moved to the client side now - I mostly work in a client success position - and haven't developed in many years. I would be entirely useless to you from a technical point of view. – MD-Tech May 15 '21 at 19:33
  • appreciate the response, if you're interested in dipping your feet on this side again do get in touch! Best of luck! – Mir May 17 '21 at 16:36
3

By default quickFix reorders tags in a group by ascending order. If you want to retain the order you need to rebuild the quick fix jar as suggested here.

halbs
  • 106
  • 1
  • 1
  • 6
0

for python: open up the quickfix file in your site-packages folder that contains the message type you want. The messages are all classes that have an "order" array that determines the order of the tags.

grantr
  • 878
  • 8
  • 16
0

Changing the order of fields in a FIX message I use Vb.net QuickFIXn.FIX5.0SP2.1.10.0

Imports QuickFix
Public Class ApplicationFixFxAll
   Inherits QuickFix.MessageCracker
   Implements QuickFix.IApplication

   Public Sub ToAdmin(message As Message, sessionID As SessionID) Implements IApplication.ToAdmin

        message.Header.HEADER_FIELD_ORDER = {8, 9, 35, 56, 34, 49, 52}
        Debug.Print($"toAdmin {Now:yyyMMdd HHmm} {message.ToString}")

    End Sub
    
    ...

End Class
Burba
  • 1
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 12 '23 at 01:42