Changing the order of fields in a FIX message
Asked Answered
D

4

7

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?

Delastre answered 9/6, 2014 at 21:6 Comment(5)
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?Radferd
Yes Grant, but you have to add them to the correct group (header, body or trailer) otherwise you get this error!Tadio
@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.Istle
@Istle 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."Radferd
@GrantBirchmeier thank you, I was able to find it now.Istle
T
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.

Tadio answered 10/6, 2014 at 8:14 Comment(3)
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!Heuser
@Heuser 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.Tadio
appreciate the response, if you're interested in dipping your feet on this side again do get in touch! Best of luck!Heuser
H
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.

Homicidal answered 25/6, 2015 at 5:6 Comment(1)
the link is broken.Jeb
C
1

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
Chandrachandragupta answered 9/6, 2023 at 20:44 Comment(1)
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.Regin
Z
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.

Zibeline answered 3/5, 2023 at 18:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.