Problem · String

FIX Message Reconciliation

Learn this problem
EasyVirtu Financial logoVirtu FinancialNEW GRADINTERNOA

Problem 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 Quantity
  • 31: Price
  • 54: Side, where 1 means Buy and 2 means Sell
  • 48: 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) → String

Examples

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

  • houseMessage and streetMessage are non-empty.
  • Each message is a sequence of well-formed tag=value fields separated by |.
  • A message may end with a trailing |.
  • Each tag appears at most once within a message.

More Virtu Financial problems

drafts saved locally
public String reconcileFixMessages(String houseMessage, String streetMessage) {
    // write your code here
}
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|"
expected"True"
checking account