Compare two FixMessages in QuickFIXJ

I need to compare two fix messages (say two ExecutionReports) in QuickFIXJ.

Let’s call them er1 and er2

Now, what I mean by comparing them is that a bunch of fields must be identical. for instance I care that tag 55, tag 207, tag 1 are the same. but not others.

It seems to me that the only way to do so is to write something as expensive (performance-wise) as this:

public static boolean compare(ExecutionReport er1,ExecutionReport er2) 
{
   StringField sf1 = new StringField(55);
   StringField sf2 = new StringField(55);

   er.getField(sf1);
   er.getField(sf2);

   if (sf1.getValue().equals(sf2.getValue())==false) return false;

   ... // continue with all of the other fields
   ... // in the same way

}

Am I missing something ? can somebody suggest a better/faster approach ?

Answer

There is no function to compare two fix messages in the API, it seems. But instead of comparing the whole message fields, the best would be to compare only those fields which are mandatory. An extension would be if you are dead sure those fields would be present in the FIX message.

Another option would be to compare in a thread different than the one for the session where you are sending and receiving messages. It would be hard to decide if the messages need to be compared in the same thread, without knowing what happens downstream with the Execution reports or what are your actions if the Execution reports match.

Leave a Reply

Your email address will not be published. Required fields are marked *