Sequence Manipulation Methods in C#

Manipulation methods reshape, re-index, or transform a sequence without leaving the C# analytics pipeline.

In the C# API, analytics operate on Sequence values obtained from OrderedSequence<T> searches, direct ordered-sequence iteration, UnorderedSequence<T>.All, or positional projections such as quote.Close[dayRange].

For an overview see page The C# Sequence Class

Operations

source.Unique()
Removes repeated adjacent values.
source.Normalize()
Normalizes the sequence by its Euclidean length.
source.Thin(ulong origin, ulong step)
Keeps every step-th value starting from origin.
source.Subseq(ulong from, ulong till)
Returns a subsequence between two positions, forward or backward.
source.Reverse()
Reverses the element order.
source.Diff()
Returns pairwise differences between adjacent values.
source.Trend()
Returns the trend sequence.
source.Repeat(int count)
Repeats each element a fixed number of times.
source.Map(Sequence positions)
Projects values at the specified positions.
source.stretch(Sequence ts1, Sequence ts2, object filler)
Stretches a sequence to the timestamps in ts1 using values from ts2.
source.Stretch0(Sequence ts1, Sequence ts2, object filler)
Stretch variant with zero-fill semantics.
source.AsofJoin(Sequence ts1, Sequence ts2)
Performs an as-of join on timestamp sequences.
source.Cast(Type elemType)
Converts the sequence to another runtime element type.
source.Cross(int firstCrossDirection)
Returns the positions of crossings.
source.Extrema(int firstExtremum)
Returns local extrema positions.
source.Hash()
Calculates element hashes.
source.Hash(Sequence other)
Calculates combined hashes against another sequence.

Example

This example extracts a subsequence from an ordered day sequence and projects aligned values from the related high-price sequence.

    ulong count = quote.Day.Count;

    using (Sequence daySlice = quote.Day.Subseq(1, count - 2))
    using (Sequence highSlice = quote.High[daySlice])
    {
        while (daySlice.Next(out uint day) && highSlice.Next(out float high))
        {
            printf("%s[%u]: %f\n", __arglist(quote.Symbol, day, (double)high));
        }
    }