Skip to content

FIX Message

Query Source: adopted from here

Introduction

The question from last week mentions that time in force is tag 59 in FIX Protocol. The Financial Information eXchange (FIX) protocol is an electronic communication protocol widely used by today's financial trading systems and trading algorithms. Both order management system (OMS) and execution management system (EMS) use FIX to communicate order/execution information to different components electronically. All these incoming or outgoing FIX messages are logged with a key/value format. For example, the following log snippet

35=D|22=RIC|48=MS.N|54=1|44=33.85|53=500|30=XNYS

might result from creating a new order sent to NYSE to buy 200 shares of Morgan Stanley at price 33.85. A good source of information on FIX message is FIXimate.

Question

Write a function parseFixMsg to parse FIX message. This function returns a dictionary with tag number/value as the key/value of the dictionary.

fixMsg:"35=D|22=RIC|48=MS.N|54=1|44=33.85|53=500|30=XNYS";
parseFixMsg[fixMsg]

Answer

Here is the simple solution.

fixMsg:"35=D|22=RIC|48=MS.N|54=1|44=33.85|53=500|30=XNYS";
parseFixMsg:{[msg](!)."S=|"0:msg};
parseFixMsg fixMsg

An acute reader might notice that the dictionary values are a string. To cast the values to proper types, some further work is required. Fortunately a nice solution is provided by one of Kx Systems' white papers. For more details, read the comprehensive article on parsing FIX messages in Kdb+ and FIX messaging.