FIX Message Reconciliation
Learn this problemProblem statement
In financial trading systems, FIX (Financial Information eXchange) messages are represented as tag=value fields separated by the pipe character |, which stands in for the SOH delimiter.
Given one House FIX message houseMessage and one Street FIX message streetMessage, compare these required tags:
32: Order Quantity31: Price54: Side, where1means Buy and2means Sell48: Security ID
Return "True" if both messages contain all four required tags and the raw value string for every required tag matches exactly. Return "False" otherwise.
The order of fields and any tags outside the required set do not affect the result.
Function
reconcileFixMessages(houseMessage: String, streetMessage: String) → StringExamples
Example 1
houseMessage = "8=FIX.4.4|11=ORD001|48=AAPL|54=1|32=1000|31=150.50|"streetMessage = "8=FIX.4.4|11=ORD001|48=AAPL|54=1|32=1000|31=150.50|"return = "True"The required values match exactly: 32=1000, 31=150.50, 54=1, and 48=AAPL.
Example 2
houseMessage = "32=250|31=99.00|54=2|48=MSFT|"streetMessage = "48=MSFT|10=abc|54=2|31=99.00|32=250|"return = "True"The required values match even though their field order differs and the Street message contains the unrelated tag 10.
Example 3
houseMessage = "32=250|31=99.0|54=2|48=MSFT|"streetMessage = "32=250|31=99.00|54=2|48=MSFT|"return = "False"The Price values 99.0 and 99.00 are numerically equal but are not exact string matches.
Constraints
houseMessageandstreetMessageare non-empty.- Each message is a sequence of well-formed
tag=valuefields separated by|. - A message may end with a trailing
|. - Each tag appears at most once within a message.