elixfix v0.0.1-dev FMsgParse

Pure functions to parse FIX messages

In this module we have the functions (quite pure) to parse FIX messages.

The main is add_char(status, char)

It will return the new status

Summary

Functions

Add a new char msg to already received chunk

Convert a string to a fix msg_map struct

Functions

add_char(status, char)

Add a new char msg to already received chunk

First parameter is status, the second one is the character to be added.

It will return the new status

Status could be…

  • StPartTag -> reading a tag
  • StPartVal -> reading a value (after =)
  • StFullMessage -> a message has been completed
  • All status has the field parsed of type Parsed with the parsed info

Examples

iex> msg =  "8=FIX.4.4|9=122|35=D|34=215|49=CLIENT12|52=20100225-19:41:57.316|56=B|1=Marcel|11=13346|21=1|40=2|44=5|54=1|59=0|60=20100225-19:39:52.020|10=072|"
iex> msg_list = String.to_char_list(String.replace(msg, "|", <<1>>))
iex> msg_list |> Enum.reduce(%FMsgParse.StFullMessage{}, &(FMsgParse.add_char(&2, &1)))
%FMsgParse.StFullMessage{parsed: %FMsgParse.Parsed{body_length: 122,
  check_sum: 72, errors: [],
  msg_map: %{:Account => "Marcel", :BeginString => "FIX.4.4", :BodyLength => "122",
           :CheckSum => "072", :ClOrdID => "13346", :HandlInst => "1", :MsgSeqNum => 215,
           :MsgType => "D", :OrdType => "2", :Price => "5", :SenderCompID => "CLIENT12",
           :SendingTime => "20100225-19:41:57.316", :Side => "1", :TargetCompID => "B",
           :TimeInForce => "0", :TransactTime => "20100225-19:39:52.020"}, num_tags: 15,
         orig_msg: "8=FIX.4.4^9=122^35=D^34=215^49=CLIENT12^52=20100225-19:41:57.316^56=B^1=Marcel^11=13346^21=1^40=2^44=5^54=1^59=0^60=20100225-19:39:52.020^10=072^",
         position: 145}}

iex> FMsgParse.add_char(%FMsgParse.StFullMessage{}, ?8)
%FMsgParse.StPartTag{chunk: "8",
 parsed: %FMsgParse.Parsed{body_length: 1, check_sum: 56, errors: [],
  msg_map: %{}, num_tags: 0, orig_msg: "8", position: 1}}
parse_string_test(string, sep \\ "|")

Convert a string to a fix msg_map struct

It is for testing support

test_parse_string()
test_parse_string_perf()