Group Aggregate Methods in C#

Group aggregate methods calculate one result for each contiguous group in an ordered grouping sequence.

Use them when the groupBy sequence is already ordered, for example after selecting a time range from an ordered sequence such as quote.Day.

For an overview see page The C# Sequence Class

Operations

source.GroupAggCount()
Counts the number of elements in each ordered group.
source.GroupAggMax(Sequence groupBy)
Returns the maximum value for each group.
source.GroupAggMin(Sequence groupBy)
Returns the minimum value for each group.
source.GroupAggFirst(Sequence groupBy)
Returns the first value for each group.
source.GroupAggLast(Sequence groupBy)
Returns the last value for each group.
source.GroupAggSum(Sequence groupBy)
Returns the sum for each group.
source.GroupAggAvg(Sequence groupBy)
Returns the average for each group.
source.GroupAggVar(Sequence groupBy)
Returns the variance for each group.
source.GroupAggVarSamp(Sequence groupBy)
Returns the sample variance for each group.
source.GroupAggDev(Sequence groupBy)
Returns the standard deviation for each group.
source.GroupAggDevSamp(Sequence groupBy)
Returns the sample standard deviation for each group.
source.GroupAggApproxDC(Sequence groupBy)
Returns the approximate distinct count for each group.
source.GroupAggApproxHashDC(Sequence groupBy)
Returns the approximate hash-based distinct count for each group.
source.GroupAggWavg(Sequence weight, Sequence groupBy)
Returns the weighted average for each group.

Example

The seqapi sample groups one year of volume values by month using the ordered day sequence.

    using (Sequence dayRange = quote.Day.Search(20130101u, SelectBoundary.Inclusive,
                                                20140101u, SelectBoundary.Exclusive))
    using (Sequence groupBy = dayRange / Sequence.Constant(con, 100u))
    using (Sequence monthlyVolume = quote.Volume[dayRange].GroupAggSum(groupBy))
    {
        PrintIntSequence(quote, monthlyVolume);
    }