Reputation: 507
For a quickfixj message like a trade capture report, it can sometimes have nested repeating group. Take a look at NYSE's trade capture report message on page 10 of their document : https://www.nyse.com/publicdocs/nyse/markets/nyse/NYSE_TRF_Messaging_Spec.pdf
Say if one needs to get a partyID(448), partyIDSource(447) and partyRole(452), how does one do it using Java and the QuickFixJ java api
Upvotes: 3
Views: 8785
Reputation: 2013
Getting sides from TradeCaptureReport and reading the party sub group as well and the sub party sub group:
try {
if (message.getNoSides() != null) {
for (int i = 1, l = message.getNoSides().getValue(); i <= l; i++) {
Group group = message.getGroup(i, NoSides.FIELD);
if (group != null && group.getField(new Side()) != null) {
// read side then other fields: group.getField(new Side()).getValue()));
try {
// get first party id group
Group partiesGroup = group.getGroup(1, NoPartyIDs.FIELD);
if (partiesGroup != null && partiesGroup.getField(new PartyID()) != null) {
// read party id: partiesGroup.getField(new PartyID()).getValue()
try {
// get first sub
Group subPartiesGroup = partiesGroup.getGroup(1, NoPartySubIDs.FIELD);
if (subPartiesGroup != null && subPartiesGroup.getField(new PartySubID()) != null) {
// read sub party id : subPartiesGroup.getField(new PartySubID()).getValue()
}
} catch (FieldNotFound e) {
log.error("Ignored error: ", e);
}
}
} catch (FieldNotFound e) {
log.error("Ignored error: ", e);
}
}
}
}
} catch (FieldNotFound e) {
log.error("Ignored error: ", e);
}
Upvotes: 0
Reputation: 18504
Getting a 2nd-level-nested is not much different than getting a 1st-level group.
I didn't read your NYSE doc, but I assume that the Parties
group is inside of the NoSides
group just like in the regular FIX44 spec.
This code would probably work. (I haven't compiled it.) I didn't do any group-count checking, but I think you know that part.
PartyID partyId = new PartyID();
// group
quickfix.fix44.TradeCaptureReport.NoSides sidesGroup =
new quickfix.fix44.TradeCaptureReport.NoSides();
// subgroup
quickfix.fix44.TradeCaptureReport.NoSides.NoPartyIDs partyIdsGroup =
new quickfix.fix44.TradeCaptureReport.NoSides.NoPartyIDs();
// get first sidesGroup
message.getGroup(1, sidesGroup);
// get first partyIdsGroup out of first sidesGroup
sidesGroup.getGroup(1, partyIdsGroup);
// do something with it...
// get second partyIdsGroup out of first sidesGroup
sidesGroup.getGroup(2, partyIdsGroup);
// do something with it...
// -----
// get second sidesGroup
message.getGroup(2, sidesGroup);
// get first partyIdsGroup out of second sidesGroup
sidesGroup.getGroup(1, partyIdsGroup);
// and so on...
Upvotes: 4