Repeating Groups
QuickFIX has the ability to send messages containing repeating groups and even recursive repeating groups. All repeating groups begin with a field that indicates how many repeating groups are in a set. A group can be created by referencing a class named after this field scoped within the parent message or group.

Creating Messages With Repeating Groups

When a message is created the required field declaring the number of repeating groups is set to zero. QuickFIX will automatically increment field for you as you add groups.

See this code in PYTHON, RUBY
    // create a market data message
    FIX42::MarketDataSnapshotFullRefresh message(FIX::Symbol("QF"));

    // repeating group in the form of MessageName::NoField
    FIX42::MarketDataSnapshotFullRefresh::NoMDEntries group;
    group.set(FIX::MDEntryType('0'));
    group.set(FIX::MDEntryPx(12.32));
    group.set(FIX::MDEntrySize(100));
    group.set(FIX::OrderID("ORDERID"));
    message.addGroup(group);

    // no need to create a new group class if we are reusing the fields
    group.set(FIX::MDEntryType('1'));
    group.set(FIX::MDEntryPx(12.32));
    group.set(FIX::MDEntrySize(100));
    group.set(FIX::OrderID("ORDERID"));
    message.addGroup(group);

Reading Messages With Repeating Groups

To pull a group out of a message you need to supply the group object you wish to pull out. You should first inspect the number of entries field (which the group is named after) to get the total number of groups. The message that was created above is now parsed in this example.

See this code in PYTHON, RUBY
    // should be 2
    FIX::NoMDEntries noMDEntries;
    message.get(noMDEntries);

    FIX42::MarketDataSnapshotFullRefresh::NoMDEntries group;
    FIX::MDEntryType MDEntryType;
    FIX::MDEntryPx MDEntryPx;
    FIX::MDEntrySize MDEntrySize;
    FIX::OrderID orderID;

    message.getGroup(1, group);
    group.get(MDEntryType);
    group.get(MDEntryPx);
    group.get(MDEntrySize);
    group.get(orderID);

    message.getGroup(2, group);
    group.get(MDEntryType);
    group.get(MDEntryPx);
    group.get(MDEntrySize);
    group.get(orderID);