elixfix v0.0.1-dev FMsgMapSupport
Support functions to deal with fix msg_map
Summary
Functions
This will check if all tags exists in message parsed
Check if tag has value on msg_map
Return int from tag
Return {[ints], [errors]} from [tags]
Functions
This will check if all tags exists in message parsed
iex> msg_map = FMsgParse.parse_string_test(
...> "8=FIX.4.1|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|")
...> .parsed.msg_map
iex> {_, errors} = FMsgMapSupport.check_mandatory_tags({msg_map, []},
...> [:BeginString, :BodyLength, :SenderCompID, :TargetCompID, :MsgSeqNum, :SendingTime, 999])
iex> errors
["missing tag 999."]
Check if tag has value on msg_map
It will receive previous errors and will add current error to this list if necessary.
iex> msg_map = FMsgParse.parse_string_test(
...> "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|")
...> .parsed.msg_map
iex> {_, errors} = FMsgMapSupport.check_tag_value({msg_map, []}, :BeginString, "FIX.4.4")
iex> errors
[]
iex> msg_map = FMsgParse.parse_string_test(
...> "8=FIX.4.1|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|")
...> .parsed.msg_map
iex> {_, errors} = FMsgMapSupport.check_tag_value({msg_map, []}, :BeginString, "FIX.4.4")
iex> errors
[" invalid tag value on: BeginString(8) received: FIX.4.1, expected FIX.4.4"]
Return int from tag
It will return
{ :ok, int_val }
{ :error, description }
iex> msg_map = FMsgParse.parse_string_test(
...> "8=FIX.4.1|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|")
...> .parsed.msg_map
iex> FMsgMapSupport.get_tag_value_mandatory_int(:ClOrdID, msg_map)
{:ok, 13346}
iex> FMsgMapSupport.get_tag_value_mandatory_int(:TargetCompID, msg_map)
{:error, "invalid val on tag TargetCompID(56)"}
Return {[ints], [errors]} from [tags]
It will return
{[ints], [errors]}
iex> msg_map = FMsgParse.parse_string_test(
...> "8=FIX.4.1|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|")
...> .parsed.msg_map
iex> FMsgMapSupport.get_tag_value_mandatory_ints(msg_map, [:BodyLength, :Price, :ClOrdID])
{[122, 5, 13346], []}
iex> FMsgMapSupport.get_tag_value_mandatory_ints(msg_map, [:BodyLength, :Price, :HandlInst, :SenderCompID, :Account])
{[122, 5, 1, nil, nil], ["invalid val on tag SenderCompID(49)", "invalid val on tag Account(1)"]}