Parse Fix Message retrieve data example

In many of previous tutorial you saw how to create fix client server and send message back and forth. In this example you will see how to parse fix message, retrieve its value:

Note: Please don’t forget to include quikfix-core jar (I have used 1.6.3 version)

  • ParseFIXMessage.java:
import quickfix.FieldNotFound;
import quickfix.InvalidMessage;
import quickfix.Message;
import quickfix.MessageParseError;
import quickfix.MessageUtils;

public class ParseFIXMessage {
	
	
public static void main(String[] args) throws MessageParseError, InvalidMessage, FieldNotFound {
		
		Message message = new Message("8=FIX.4.29=020535=D49=DEAN356=MSRX334=466252=20160621-12:31:08128=MSCO10016=DEAN55=AIZ54=238=1340=159=047=I18=563=021=160=20160621-12:31:07100=N11=SOS045920160621083107682S/AIZ9321=EQ2016062108310768210=046");
		
		String fixMessage = message.toString();
		
		System.out.println("Origional FIX message:-->"+fixMessage+"\n");
		System.out.println(MessageUtils.getStringField(fixMessage, 8));
		System.out.println(MessageUtils.getStringField(fixMessage, 9));
		System.out.println(MessageUtils.getStringField(fixMessage, 35));
		System.out.println(MessageUtils.getStringField(fixMessage, 49));
		System.out.println(MessageUtils.getStringField(fixMessage, 56));
		System.out.println(MessageUtils.getStringField(fixMessage, 34));
		System.out.println(MessageUtils.getStringField(fixMessage, 52));
		System.out.println(MessageUtils.getStringField(fixMessage, 128));
		System.out.println(MessageUtils.getStringField(fixMessage, 10016));
		System.out.println(MessageUtils.getStringField(fixMessage, 55));
		System.out.println(MessageUtils.getStringField(fixMessage, 54));
		System.out.println(MessageUtils.getStringField(fixMessage, 38));
		System.out.println(MessageUtils.getStringField(fixMessage, 40));		
		System.out.println(MessageUtils.getStringField(fixMessage, 59));
		System.out.println(MessageUtils.getStringField(fixMessage, 47));
		System.out.println(MessageUtils.getStringField(fixMessage, 18));
		System.out.println(MessageUtils.getStringField(fixMessage, 63));
		System.out.println(MessageUtils.getStringField(fixMessage, 21));
		System.out.println(MessageUtils.getStringField(fixMessage, 60));
		System.out.println(MessageUtils.getStringField(fixMessage, 100));
		System.out.println(MessageUtils.getStringField(fixMessage, 11));
		System.out.println(MessageUtils.getStringField(fixMessage, 9321));
		System.out.println(MessageUtils.getStringField(fixMessage, 10));
 
	}
 

}

Reference: Quick fix

Leave a Reply

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