Class IndicatorExtensions
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
leftIIndicator<TLeft, TSample, TL>The left source indicator.
rightIIndicator<TRight, TSample, TR>The right source indicator.
fFunc<TL, TR, TResult>Pure function combining both current values.
Returns
- CombinedIndicator<TLeft, TRight, TSample, TL, TR, TResult>
Type Parameters
TLeftThe left indicator's concrete type.
TRightThe right indicator's concrete type.
TSampleThe sample type both indicators consume.
TLThe left indicator's value type.
TRThe right indicator's value type.
TResultThe 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
indicatorIIndicator<TSelf, TSample, TValue>The source indicator.
fFunc<TValue, TResult>Pure function from the source value to the derived value.
Returns
- MappedIndicator<TSelf, TSample, TValue, TResult>
Type Parameters
TSelfThe source indicator's concrete type.
TSampleThe sample type both indicators consume.
TValueThe source indicator's value type.
TResultThe derived indicator's value type.
Remarks
Realises the map combinator (§10.4).