Convert FIX Message String

Convert FIX Message String

In last tutorial we saw how to convert Stirng to FIX message, FIX to XML, Parse FIX message etc…In this we will convert FIX message to String using NewOrderSingle class. As we have many options are avaible to convert FIX message this is one the one where could set all your order attribute which you want to pass to the exchagne. Please have example below:

Note: To run this example you will quickfixj-all-1.6.0.jar or any latest version of it which you could download from QuickFix site.

  • ConvertFIXMessageToString.java:
package com.javahonk;

import java.util.Date;

import quickfix.field.ClOrdID;
import quickfix.field.HandlInst;
import quickfix.field.OrdType;
import quickfix.field.OrderQty;
import quickfix.field.Price;
import quickfix.field.Side;
import quickfix.field.Symbol;
import quickfix.field.TransactTime;
import quickfix.fix42.NewOrderSingle;

public class ConvertFIXMessageToString {

	public static void main(String[] args) {
		NewOrderSingle order = new NewOrderSingle(new ClOrdID("123456788"),
				new HandlInst(HandlInst.MANUAL_ORDER), new Symbol("AAPL"),
				new Side(Side.BUY), new TransactTime(new Date()), new OrdType(OrdType.MARKET));
		
		order.set(new OrderQty(203.33));
		order.set(new Price(400.69));
		System.out.println(order.toString());

	}

}
  • Output:

Convert FIX Message String

Leave a Reply

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