Table of Contents

Struct SumIndicator<TInner, TSample, TValue>

Namespace
Virtufin.Core.Behavior
Assembly
Virtufin.Core.dll

Result of Sum<TSelf, TSample, TValue>(IIndicator<TSelf, TSample, TValue>, int). Maintains an O(1)-amortized running sum over a sliding last-N window.

public readonly struct SumIndicator<TInner, TSample, TValue> : IIndicator<SumIndicator<TInner, TSample, TValue>, TSample, (TValue Sum, int Count)>, ISignal<(TValue Sum, int Count)> where TInner : IIndicator<TInner, TSample, TValue> where TValue : IAdditionOperators<TValue, TValue, TValue>, ISubtractionOperators<TValue, TValue, TValue>

Type Parameters

TInner

The wrapped indicator's concrete type.

TSample

The sample type consumed on each observation.

TValue

The wrapped indicator's value type.

Implements
IIndicator<SumIndicator<TInner, TSample, TValue>, TSample, (TValue Sum, int Count)>
ISignal<(TValue Sum, int Count)>
Inherited Members
Extension Methods

Properties

Value

The current signal value.

public (TValue Sum, int Count) Value { get; }

Property Value

(TValue Sum, int Count)

Remarks

Count is the live in-window count (≤ the requested window size, less until the window fills) — needed by any caller dividing the sum into an average.

Methods

Add(TSample)

Fold one more sample in, returning the updated indicator.

public SumIndicator<TInner, TSample, TValue> Add(TSample sample)

Parameters

sample TSample

The new observation.

Returns

SumIndicator<TInner, TSample, TValue>

A new indicator instance reflecting sample.