Table of Contents

Class IndicatorExtensions

Namespace
Virtufin.Core.Behaviour
Assembly
Virtufin.Core.dll

Pure combinators over IIndicator<TSelf, TSample, TValue> — the foldable counterparts of SignalExtensions's map/zip (domain spec §10.4). An indicator's current value can't be derived from another indicator's value alone the way a plain ISignal<T> can, because the combinator itself must stay foldable — it needs an Add(TSample) that threads new samples into the wrapped indicator(s). Each combinator therefore returns a small concrete wrapper type (not just the IIndicator<TSelf, TSample, TValue> interface) so the self-referential TSelf constraint has something nameable to bind to, and so the result can itself be composed further.

public static class IndicatorExtensions
Inheritance
IndicatorExtensions
Inherited Members

Methods

Combine<TLeft, TRight, TSample, TL, TR, TResult>(IIndicator<TLeft, TSample, TL>, IIndicator<TRight, TSample, TR>, Func<TL, TR, TResult>)

Derive an indicator by fanning one incoming sample out to two indicators of the same sample type and combining their current values (e.g. a fast/slow moving-average spread for a golden-cross signal).

public static CombinedIndicator<TLeft, TRight, TSample, TL, TR, TResult> Combine<TLeft, TRight, TSample, TL, TR, TResult>(this IIndicator<TLeft, TSample, TL> left, IIndicator<TRight, TSample, TR> right, Func<TL, TR, TResult> f) where TLeft : IIndicator<TLeft, TSample, TL> where TRight : IIndicator<TRight, TSample, TR>

Parameters

left IIndicator<TLeft, TSample, TL>

The left source indicator.

right IIndicator<TRight, TSample, TR>

The right source indicator.

f Func<TL, TR, TResult>

Pure function combining both current values.

Returns

CombinedIndicator<TLeft, TRight, TSample, TL, TR, TResult>

Type Parameters

TLeft

The left indicator's concrete type.

TRight

The right indicator's concrete type.

TSample

The sample type both indicators consume.

TL

The left indicator's value type.

TR

The right indicator's value type.

TResult

The derived indicator's value type.

Remarks

Realises the zip combinator (§10.4).

Map<TSelf, TSample, TValue, TResult>(IIndicator<TSelf, TSample, TValue>, Func<TValue, TResult>)

Derive an indicator whose value is a pure function of another indicator's current value (e.g. an SMA in price units mapped to bps).

public static MappedIndicator<TSelf, TSample, TValue, TResult> Map<TSelf, TSample, TValue, TResult>(this IIndicator<TSelf, TSample, TValue> indicator, Func<TValue, TResult> f) where TSelf : IIndicator<TSelf, TSample, TValue>

Parameters

indicator IIndicator<TSelf, TSample, TValue>

The source indicator.

f Func<TValue, TResult>

Pure function from the source value to the derived value.

Returns

MappedIndicator<TSelf, TSample, TValue, TResult>

Type Parameters

TSelf

The source indicator's concrete type.

TSample

The sample type both indicators consume.

TValue

The source indicator's value type.

TResult

The derived indicator's value type.

Remarks

Realises the map combinator (§10.4).