Monday, March 7, 2016

Fix protocol

Hello, welcome back to my blog about automated trading. Two weeks ago I have finished the chapter about back testing and presented stand alone program for it. This week I am going to talk about fix protocol.

For the source code, please download repository and update to branch 7-fix-protocol, changeset b386cea63bc9.

Background

Fix protocol is standard for financial information exchange. Broker typically uses fix for sending an orders to buy or sell and for account monitoring (although some brokers have proprietary protocol). Comparing to the messages related to historical quotes or real time quotes fix protocol is pretty complex. It has well defined method for session management (including recovery of the lost messages) and messages are guaranteed to be processed in order. On top of this some institutions requires encryption. All this complexity brings me up to the point. It is better to use a library than trying to implement whole fix on my own (although I would be capable to do it, but this is not where I want to spend time). As I made research the freely available implementation is called QuickFix/J. Actually was not able to find any other good and free implementation. Do you know some?

Coding

My implementation of fix protocol is very simple. It is build up as a wrapper for QuickFix/J implementation. Purpose is to decouple third party library from my own standardized code. In this way I keep my independence and ability to use different implementation in the future. So now let's go through points to look at.

The first point is the application pom file. I have introduced new repository - Marketcetera. This allows me to include QuickFix as a dependency so there is no need to do any special steps in the build system.

And second point is the code itself. The main interface is calle FixEngine and implementation is  QuickFixJInitiatorFixEngine. From there you can track to the FixReceiver and FixMessage. To see everything in action, please look to the unit test. Have fun!

That's it for today. Next week I will summarize the APIs we have so far. Thank you for reading!

No comments:

Post a Comment