Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a String FIX message to FIX FIX50SP2 format using QuickFixJ

Need a quick help. I am a newbie in QuickFixJ. I have a FIX message in a txt file. I need to convert that into FIX50SP2 format. I am enclosing the code snippet.

String fixMsg = "1128=99=25535=X49=CME34=47134052=20100318-03:21:11.36475=20120904268=2279=122=848=336683=607400107=ESU2269=1270=140575271=152273=121014000336=2346=521023=1279=122=848=336683=607401107=ESU2269=1270=140600271=206273=121014000336=2346=681023=210=159";

System.out.println("FixMsg String:"+fixMsg);
Message FIXMessage = new Message();
DataDictionary dd = new DataDictionary("FIX50SP2.xml");
FIXMessage.fromString(fixMsg, dd, false);
System.out.println("FIXMessage Output:" + FIXMessage.toString()); // Print message after parsing
MsgType msgType = new MsgType();
System.out.println(FIXMessage.getField(msgType));

Here is the output:

FixMsg String:1128=99=15835=X49=CME34=47164052=2012090312102051175=20120904268=1279=122=848=336683=607745107=ESU2269=1270=140575271=123273=121020000336=2346=501023=110=205
FIXMessage Output:9=6135=X34=47164049=CME52=2012090312102051175=20120904268=110=117
quickfix.FieldNotFound: Field [35] was not found in message.
    at quickfix.FieldMap.getField(FieldMap.java:216)
    at quickfix.FieldMap.getFieldInternal(FieldMap.java:353)
    at quickfix.FieldMap.getField(FieldMap.java:349)
    at MainApp.main(MainApp.java:52)

I want to extract MsgType field (field 35). Could you please tell me where I am wrong? The thing I have observed is that after parsing to FIX50SP2 format, the convert FIX message is missing many data element (for details see the output)

Thanks

like image 323
Rivu Avatar asked Oct 22 '22 03:10

Rivu


1 Answers

Like others mentioned the MsgType is an header field and you get it by using the following

String msgType = null;
if(FIXMessage.getHeader().isSetField(MsgType.FIELD)) {
    msgType = FIXMessage.getHeader().getString(MsgType.FIELD);
}
System.out.println("MsgType is " + msgType);`

The reason you are missing many data element after parsing is, probably your message have some custom tags(like tag 2346), which is not defined in your data dictionary(FIXSP02.xml). hence the parsing of those tags failed and missing in the output.

To fix this, get the data dictionary from the party that is sending you the message and use it to parse the message

like image 131
Kalatta Avatar answered Nov 01 '22 07:11

Kalatta