3

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

Kaleb Blue
  • 487
  • 1
  • 5
  • 20

2 Answers2

4

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...
Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
  • is there a way to programatically set the groups without doing 1,2, etc.. – kgui May 24 '17 at 19:18
  • Use a loop and incrementing int variable. (This answer is so obvious that I wonder if I am misunderstanding your question.) – Grant Birchmeier May 24 '17 at 19:33
  • Let's say I get a FIX message, I would like to set up some code to get all the groups and a field within the group without me changing the source code. Then, I get another FIX message, with a different number of groups but, still want the same source to work. I'd like the source code to handle those scenarios. – kgui May 24 '17 at 19:42
  • Read the group's counter field. For instance, in the above answer, you can extract the `NoSides` integer field. That value is how many `Side` elements you will need to loop over. – Grant Birchmeier May 24 '17 at 19:43
0

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);
            }
user666
  • 1,750
  • 3
  • 18
  • 34