• Version 1.15.2
Show / Hide Table of Contents

Flat Group Reader

The FlatGroupReader class provides a convenient way to access repeating group fields of the Flat Message.

Constructors

The Flat Group Reader constructors take either the full description of the FIX repeating group structure or the number of entries tag.

Top Level Repeating Groups

To read top-level repeating group fields, use the Wrap(FlatMessage) method to attach the reader to the source Flat Message.

Reading Fields

Use the MoveNext() method to move the reader to the next repeating group entry.

Required Fields

To read the required field values of the current repeating group entry, use one of the following methods:

  • Get(int)
  • Get(int, out Field)
  • GetBytes(int)
  • GetChar(int)
  • GetDecimal(int)
  • GetDouble(int)
  • GetFlag(int)
  • GetHighResolutionTimeSpan(int)
  • GetHighResolutionTimeSpan(int, out TimeSpanFormat)
  • GetHighResolutionTimestamp(int)
  • GetHighResolutionTimestamp(int, out TimestampFormat)
  • GetInteger(int)
  • GetLong(int)
  • GetSpan(int)
  • GetTimeSpan(int)
  • GetTimeSpan(int, out TimeSpanFormat)
  • GetTimestamp(int)
  • GetTimestamp(int, out TimestampFormat)

For example:

var reader = new FlatGroupReader(new FieldInfo(Tag.NoMDEntryTypes, new FieldInfo(Tag.MDEntryType)));

var message = new FlatMessage(ProtocolVersion.Fix44);

// See https://www.onixs.biz/fix-dictionary/4.4/msgType_V_86.html.
message.Set(Tag.MsgType, MsgType.MarketDataRequest);
message.Add(Tag.NoMDEntryTypes, 3)
       .Add(Tag.MDEntryType, MDEntryType.Bid)
       .Add(Tag.MDEntryType, MDEntryType.Offer)
       .Add(Tag.MDEntryType, MDEntryType.Trade);

reader.Wrap(message);

int index = 0;
while (reader.MoveNext())
{
    System.Console.WriteLine("Market Data Entry # " + index + " : MDEntryType = " + reader.Get(Tag.MDEntryType));
    index++;
}

Option Fields

To read optional field values of the current repeating group entry, use one of the following methods:

  • TryGet(int, out string)
  • TryGetBytes(int, out byte[])
  • TryGetChar(int, out char)
  • TryGetDecimal(int, out decimal)
  • TryGetDouble(int, out double)
  • TryGetFlag(int, out bool)
  • TryGetHighResolutionTimeSpan(int, out HighResolutionTimeSpan)
  • TryGetHighResolutionTimeSpan(int, out HighResolutionTimeSpan, out TimeSpanFormat)
  • TryGetHighResolutionTimestamp(int, out HighResolutionTimestamp)
  • TryGetHighResolutionTimestamp(int, out HighResolutionTimestamp, out TimestampFormat)
  • TryGetInteger(int, out int)
  • TryGetLong(int, out long)
  • TryGetSpan(int, out ReadOnlySpan<byte>)
  • TryGetTimeSpan(int, out TimeSpan)
  • TryGetTimeSpan(int, out TimeSpan, out TimeSpanFormat)
  • TryGetTimestamp(int, out DateTime)
  • TryGetTimestamp(int, out DateTime, out TimestampFormat)

Nested Repeating Groups

To read nested repeating group fields, use the Wrap(FlatGroupReader) method to attach the reader to the parent reader.

var message = new FlatMessage(ProtocolVersion.Fix44);

// See https://www.onixs.biz/fix-dictionary/4.4/msgType_D_68.html.
message.Set(Tag.MsgType, MsgType.NewOrderSingle);

message.Add(Tag.ClOrdID, "ClOrdID value")
    // Parent Repeating Group
    .Add(Tag.NoPartyIDs, 1)
    .Add(Tag.PartyID, "Party ID value")
    // Nested repeating group:
    .Add(Tag.NoPartySubIDs, 3)
    .Add(Tag.PartySubID, "PartySubID value0")
    .Add(Tag.PartySubID, "PartySubID value1")
    .Add(Tag.PartySubID, "PartySubID value2");

var partiesGroup = new FlatGroupReader(Tag.NoPartyIDs);
partiesGroup.Wrap(message);

var partiesSubGroup = new FlatGroupReader(Tag.NoPartySubIDs);

while (partiesGroup.MoveNext())
{
    partiesSubGroup.Wrap(partiesGroup);

    int nestedIndex = 0;
    while (partiesSubGroup.MoveNext())
    {
        System.Console.WriteLine("Parties SubGroup # " + nestedIndex + " : PartySubID = " + partiesSubGroup.Get(Tag.PartySubID));
        nestedIndex++;
    }
}

See Also

  • FIX Repeating Group introduction
  • The FlatGroupReader sample from the FIX Engine distribution package
In this article
Back to top Copyright © Onix Solutions.
Generated by DocFX