3

I am a newbie with a quick fix but trust me, I have searched all the forums thoroughly and haven't found the solution to this scenario. I am using quick fix 1.6 libs. I have a FIX message which has got a repeating group. When I send this message using sendToTarget() method, the message is forwarded to the FIX server without issues, but the fields get reordered due to which exchange rejects it. Reading through the posts, I got to know that using data dictionary will solve the problem. But when I use data dictionary with the same message I get "quick fix.InvalidMessage: Equal sign not found in field" exception. I know it's a valid message as per the data dictionary. Below are the message and code. Can someone please help. Thanks in advance.

FIX Message: 8=FIXT.1.1|9=00331|35=AE|49=AAA_FIX|56=BBB_FIX|34=29|52=20170124-09:47:14|1041=firm_trade_id_07|48=XS0102233434|22=4|25004=GBP|470=ZZ|32=100|31=6.33|15=GBP|64=20170125|60=20170124-09:47:14|1430=O|574=1|487=0|552=2|54=1|528=P|29=4|581=3|453=1|448=H7XNBB4851XX0REQ1F70|447=N|452=1|54=2|453=1|448=549300F2CCROIO4RRZ97|447=N|452=17|10=189|


Code:

BufferedReader reader = new BufferedReader(new FileReader ("Message.txt"));
String line = null;
StringBuilder stringBuilder = new StringBuilder();
String ls = System.getProperty("line.separator");

while((line = reader.readLine()) != null) {
    stringBuilder.append(line);
    stringBuilder.append(ls);
}

String messageString = stringBuilder.toString();
messageString = messageString.replace('|','\u0001');
Message FIXOrder = new Message(messageString, new DataDictionary("DD.xml"));

-Cheers MJ

James
  • 1,095
  • 7
  • 20
Mayank Jain
  • 31
  • 1
  • 2
  • What re-ordering is taking place? Tags within a repeating group have to be in a fixed order. – user1717259 Feb 17 '17 at 14:37
  • tags get rearranged in increasing order when not using DataDictionary. And it fails with above error when using DataDictionary. – Mayank Jain Feb 18 '17 at 10:34
  • 1
    This parse just fine in the example you've provided, so I suspect the issue is in your file Message.txt. Could you please add a System.out.println(messageString); so that we really know which string is being parsed? Two other remarks: * the way you read the file looks odd;what is the purpose of stringBuilder.append(ls); in your loop? * the repeating group 453 appears two times in your FIX message. It should appear once as: 453=2|448=H7XNBB4851XX0REQ1F70|447=N|452=1|448=549300F2CCROIO4RRZ97|447=N|452=17| – Regis Alenda Feb 22 '17 at 11:35
  • This error would disclose the message data that didn't contain an equals sign? – James Feb 24 '17 at 20:56
  • Assuming the FIX message supplied causes the error, I think @regis-alenda has noticed an error: the repeated group PartyId (Tag: 453 NoPartyIds) is set to 1 in your message (453=1), though there are obviously 2 groups the executing firm and the contra firm and as pointed out by Regis should be set to 2 (453=2) – James Feb 24 '17 at 20:57
  • 453 is a subgroup inside 552 so I think it can repeat. Even then, I changed the message to have only one 453 as suggested by @Regis Alenda. It still throws same error. I also added print statement and here is the output. – Mayank Jain Mar 01 '17 at 16:28
  • Output: MessageString: 8=FIXT.1.19=0033135=AE49=AAA_FIX56=TRADECHO34=2952=20170124-09:47:141041=firm_trade_id_0748=XS010230772422=425004=GBP470=ZZ32=10031=6.3315=GBP64=2017012560=20170124-09:47:141430=O574=1487=0552=254=1528=P29=4581=3453=2448=H7FNTJ4851HG0EXQ1Z70447=N452=1448=549300L2WXROIO4RYU97447=N452=1710=189 .... .... – Mayank Jain Mar 01 '17 at 17:10
  • and here is the error : quickfix.InvalidMessage: Equal sign not found in field in 8=FIXT.1.19=0033135=AE49=AAA_FIX56=TRADECHO34=2952=20170124-09:47:141041=firm_trade_id_0748=XS010230772422=425004=GBP470=ZZ32=10031=6.3315=GBP64=2017012560=20170124-09:47:141430=O574=1487=0552=254=1528=P29=4581=3453=2448=H7FNTJ4851HG0EXQ1Z70447=N452=1448=549300L2WXROIO4RYU97447=N452=1710=189 at quickfix.Message.extractField(Message.java:744) at quickfix.Message.parseTrailer(Message.java:655) at quickfix.Message.parse(Message.java:476).. ... – Mayank Jain Mar 01 '17 at 17:53
  • Could we see the dictionary for that message? Could tag 10 (Checksum) be duplicated in the message definition (e.g., one occurrence in the message def, the other in the trailer component). – Regis Alenda Mar 05 '17 at 22:47
  • Also check if you do not have another field that has id '10' due to a typo. – Regis Alenda Mar 05 '17 at 22:48
  • Hi, I got FIX Service provide to give me the Data Dictionary they are using and I have used the same and built the code base with it. I can even see classes have got created for the custom filed so I can confirm build was fine. The "equal to sign..." error has gone now but when I still create FIX message using Message.fromString (String , DataDIctionary, Validation ) method, the fields inside repeating group get rearranged and message become invalid. – Mayank Jain Mar 16 '17 at 17:08
  • I have tried everything I could and am frustrated on the fact that quick fix rearranges all fields in increasing order. Don't know how to progress. Any help is appreciated. – Mayank Jain Mar 16 '17 at 17:09

1 Answers1

7

I had the same exception and had managed to find the root cause of it.

Most likely it arises from the fact the the FIX message string was loaded from file, and possibly has: \n or \r\n at the end of the string.

Then.... when parsing the 'trailer' the last chars are failing because of the fact that the = is not found.

Equal sign not found in field

try: public static final String NEW_LINE = System.getProperty("line.separator");

  1. remove all line-seperators: String msgText= loadedText.replace(NEW_LINE, "");
  2. change delimiter to SOH (if required) msgText = msgText.replace(';', '\001');
  3. Then use the quickFix fromString: message.fromString(msgText, dataDictionary, false);
Erik
  • 2,137
  • 3
  • 25
  • 42
ellevy
  • 71
  • 1
  • 4
  • Also, if one of those separators was missing before you do the replace, it can make for a long day of hunting. Make sure to inspect each tag for validity. – bdetweiler Sep 12 '19 at 19:24