Constructing Customized Options vs. Purchase-and-Construct Software program

The Challenges of Constructing a FIX Protocol

The primary day I used to be launched to FIX was after I labored at an funding financial institution in London as a developer, I used to be informed to put in writing a feed handler to retrieve market information. Keep in mind that at the moment, I knew nothing about FIX, aside from googling it for about 10 minutes on the web. With a contact of overconfidence and slight vanity, I set to work coding a direct socket connection to the distant FIX endpoint, pondering, “How onerous may or not it’s?”

So, What Is FIX? 

Monetary Data eXchange (FIX) is each a market information format and a protocol: it’s utilized by funding banks to put orders and obtain market information and has develop into a world language in monetary buying and selling. The format of a FIX message controls how it’s encoded. All FIX messages begin with 8=FIX, which denotes the beginning of a FIX message. They then go on to record key and worth pairs. The keys are represented as numbers (referred to as TagNumbers) adopted by a = delimiter to delimit the values. Every key=worth mixture is then delimited by the u0001 character, which is usually visually represented as both ^ or |. The worth is commonly written in a semi-human-readable format. I say semi-human readable as a result of more often than not it’s human-readable, however all too usually, FIX will use a single character to indicate a state or kind of message. These characters are usually not all the time that apparent. I agree that the character B for “Purchase” and S for “Promote” is sensible, however different characters are used that make no sense. For instance, D denotes a “New Order Single” message, which is a message that’s usually used whenever you want to place an order along with your counterparty. 

An example FIX message in FIX format

Picture 1: An instance FIX message in FIX format

On the subject of the FIX protocol, it’s a must to watch out, because it seems to be far more concerned than simply having the right FIX message format and with the ability to decode the key=worth pairs. The protocol additionally contains guaranteeing the counterparty has efficiently logged in and that any missed messages are retransmitted. It additionally requires help for hole fills and sequence resets. 

Again once more to the coding: The primary problem was to get previous the login section. It appeared like this login message was obligatory! Over time, I managed to place collectively sufficient of a login message that the opposite finish got here again with a login reply, but it surely was not lengthy earlier than my colleagues began taunting me, saying, “Why don’t you simply use Quick/FIX4J?”

Saving face and making an attempt to not present that I knew nothing about QuickFIX, I quietly down my IDE and jumped again onto the net browser. Whereas doing a little bit of analysis about QuickFIX, I used to be pondering, “Maybe utilizing this open-source library may very well be easier than implementing all of it myself,” and, “Possibly it’s going to take me longer to grasp use this library.”

The library was in depth, they usually clearly put quite a lot of work into it, however I used to be overwhelmed by how sophisticated all of it appeared. I assumed, “Does it actually must be like this?”

On the time, I used to be working alongside a workforce of builders that I appeared as much as. These guys stood by the “no code is the quickest code” mantra. The whole lot they wrote was tremendous optimum: they’d work with uncooked byte buffers reasonably than create undesirable objects, and their Java code appeared extra like “C” code than any Java I had ever seen earlier than.

So, I received again to my PC and proceeded to implement the light-weight uncooked byte buffer parser route. Over the subsequent few weeks, I used to be beginning to get end-to-end information going by means of the FIX adapter, and after I was completed, it screened.

Now trying again on these early days, I ponder,  “Did I make the fitting determination? Ought to I’ve carried out it myself?” The reply is, I believe, sure. It was finest to implement the customized easy, light-weight answer that I ended up with, however I solely received away with it as a result of I had an very simple FIX use case. I used to be solely connecting a single session to a single counterparty with a single model of FIX and, aside from the login and heartbeat messages, only a single message.

My downside would have been if later this was to be upgraded to a different FIX model, we needed to help resend-requests, sequence resets, and hole fills, or provide manufacturing help and a dashboard the place administering present working periods on the dwell system.

Example dashboard for FIX sessions

Picture 2: Instance dashboard for FIX periods

At this level, it turns into a severe endeavor, and it begins to make extra sense to show to a tried and examined answer, already with all these bells and whistles, to make use of merchandise with the flexibility to go looking historic FIX messages: 

Searching for all FIX messages with a given client order id

Picture 3: Trying to find all FIX messages with a given shopper order id

Or, to lift alerts when periods disconnect:

Alerts being raised in FIX UI

Picture 4: Alerts being raised in FIX UI

Not lengthy after, I joined an organization based by Peter Lawrey. Peter is a type of super-optimal builders I discussed earlier. He developed the extensively used open-source software program Chronicle Queue and Chronicle Map. Collectively, we set to work and constructed such a FIX engine that has all these bells and whistles, and in doing so, we additionally constructed an organization that has grown to a workforce of over 20 folks.

Wanting again, builders can save effort and time utilizing a buy-and-build software program answer. As talked about, I might have been caught if we had needed to supply manufacturing help with my easy answer. Furthermore, I definitely would have wanted extra time to construct a UI. The lesson discovered was: “Generally time spent reinventing the wheel ends in a revolutionary new rolling machine. However generally it simply quantities to time spent reinventing the wheel.