I’m going to be writing a series of tutorials on using QuickfixJ to implement a simple financial application. While I hope others can benefit from the tutorial, my primary purpose is so that I can actually get more comfortable with Java after having worked with C++ for my entire career.
QuickfixJ is a Java implementation of the popular open-source Quickfix C++ library that provides a FIX protocol engine for financial applications. FIX is a simple text-based protocol built on TCP that consists of key-value fields separated by commas, where the keys are numerical indexes that have predefined and user-defined meanings. There is also an XML version of the protocol, known as FIXML, though it is not utilized in industry as often due to the extra overhead of processing the larger XML messages.
Before we get started with QuickfixJ, we should set up our development environment. The first step is to do yourself a favor and download Apache Ant. While you could use makefiles or just build everything from the command line, Ant was made for building Java projects and if you plan to grow your application in any way, Ant will save you a lot of headaches a long the way. From the Apache Ant project page you can download the libraries as-is and run it on your system. Install Ant to your system path, and then run the following command to make sure that Ant is in your path and you’re ready to use it:
trantor:Development$ ant -v Apache Ant version 1.7.1 compiled on October 13 2009 Buildfile: build.xml does not exist! Build failed
Next, download QuickfixJ from the project website. After you get everything uncompressed, take a look inside:
trantor:Development$ ls quickfixj/ LICENSE quickfixj-msg-fix41-1.4.0.jar bin quickfixj-msg-fix42-1.4.0.jar doc quickfixj-msg-fix43-1.4.0.jar etc quickfixj-msg-fix44-1.4.0.jar lib quickfixj-msg-fix50-1.4.0.jar quickfixj-all-1.4.0.jar quickfixj-msg-fixt11-1.4.0.jar quickfixj-core-1.4.0.jar src quickfixj-examples-1.4.0.jar src.zip quickfixj-msg-fix40-1.4.0.jar
QuickfixJ supports multiple versions of the FIX protocol, and you can either build with the Java library for your desired version of the protocol, or build with the quickfixj-all library that includes all versions of the protocol. Look in the lib folder too, as it contains the other required libraries.
Finally, lets set up a skeleton Ant build file that we can use to build and run our code later. If you simply run “ant” in the working directory, it looks for a build.xml file. We can specify a default target so that when we type “ant” on the command line, it does what we expect, just as we would with makefiles.
<project default="run"> <path id="project.class.path"> <!-- QuickfixJ libraries --> <pathelement location="/Users/globalengineer/Development/quickfixj/quickfixj-all-1.4.0.jar"/> <pathelement location="/Users/globalengineer/Development/quickfixj/lib/slf4j-api-1.5.3.jar"/> <pathelement location="/Users/globalengineer/Development/quickfixj/lib/slf4j-jdk14-1.5.3.jar"/> <pathelement location="/Users/globalengineer/Development/quickfixj/lib/mina-core-1.1.0.jar"/> <!-- Project directory--> <pathelement location="."/> </path> <target name="compile"> <javac srcdir="."> <classpath refid="project.class.path"/> </javac> </target> <target name="jar depends="compile"> <jar destfile="" basedir="." includes="**/*.class"> <manifest> <attribute name="Main-Class" value=""/> </manifest> </jar> </target> <target name="run" depends="jar"> <java classname="" fork="true"> <classpath refid="project.class.path"/> <arg value="config.cfg"/> </java> </target> <target name="clean"> <delete> <fileset dir="." includes="*.class"/> <fileset dir="." includes="*.jar"/> </delete> </target> </project>
The Ant build file contains targets for compiling, creating executable jars, running jars, and cleaning up the workspace. The classpath is specified in a single place so that we can add libraries that can be utilized by both the the compile and run targets. Stay tuned for future tutorials on using QuickfixJ to implement a financial application.