Class Returns
Return indicators composed purely from Combine<TLeft, TRight, TSample, TL, TR, TResult>(IIndicator<TLeft, TSample, TL>, IIndicator<TRight, TSample, TR>, Func<TL, TR, TResult>)
and Lag<TSelf, TSample, TValue>(IIndicator<TSelf, TSample, TValue>, int) — no bespoke
wrapper types needed, since Combine already returns a concrete
CombinedIndicator<TLeft, TRight, TSample, TL, TR, TResult>.
public static class Returns
- Inheritance
-
Returns
- Inherited Members
Remarks
source.Combine(source.Lag(lag), ...) folds each incoming sample into
two independent copies of the source indicator's state (one direct, one
wrapped inside Lag) — an existing property of Combine's
fan-out design, not new here; harmless for cheap arithmetic folds.
Methods
AbsoluteReturn<TSelf, TSample, TValue>(IIndicator<TSelf, TSample, TValue>, int)
The absolute return over lag samples:
current - previous.
public static CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue> AbsoluteReturn<TSelf, TSample, TValue>(this IIndicator<TSelf, TSample, TValue> source, int lag = 1) where TSelf : IIndicator<TSelf, TSample, TValue> where TValue : ISubtractionOperators<TValue, TValue, TValue>
Parameters
sourceIIndicator<TSelf, TSample, TValue>The source indicator (e.g. a price).
lagintHow many samples back to compare against. Defaults to 1.
Returns
- CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue>
Type Parameters
TSelfTSampleTValue
LogReturn<TSelf, TSample>(IIndicator<TSelf, TSample, double>, int)
The log return over lag samples: ln(current / previous).
Works directly for double via .NET's generic-math
ILogarithmicFunctions<double>; for other value types
(e.g. DecimalAmount, which doesn't implement it), use the
overload that takes an explicit log delegate.
public static CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, double>, TSample, double, double, double> LogReturn<TSelf, TSample>(this IIndicator<TSelf, TSample, double> source, int lag = 1) where TSelf : IIndicator<TSelf, TSample, double>
Parameters
sourceIIndicator<TSelf, TSample, double>The source indicator (e.g. a price).
lagintHow many samples back to compare against. Defaults to 1.
Returns
- CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, double>, TSample, double, double, double>
Type Parameters
TSelfTSample
LogReturn<TSelf, TSample, TValue>(IIndicator<TSelf, TSample, TValue>, int, Func<TValue, TValue, TValue>)
The log return over lag samples, for value types
without a built-in logarithm (e.g. DecimalAmount) — the caller
supplies log as (current, previous) => ln(current / previous)
in whatever representation TValue uses.
public static CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue> LogReturn<TSelf, TSample, TValue>(this IIndicator<TSelf, TSample, TValue> source, int lag, Func<TValue, TValue, TValue> log) where TSelf : IIndicator<TSelf, TSample, TValue>
Parameters
sourceIIndicator<TSelf, TSample, TValue>The source indicator (e.g. a price).
lagintHow many samples back to compare against.
logFunc<TValue, TValue, TValue>Computes the log return from the current and lagged values.
Returns
- CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue>
Type Parameters
TSelfTSampleTValue
RelativeReturn<TSelf, TSample, TValue>(IIndicator<TSelf, TSample, TValue>, int)
The relative (simple) return over lag samples:
(current - previous) / previous.
public static CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue> RelativeReturn<TSelf, TSample, TValue>(this IIndicator<TSelf, TSample, TValue> source, int lag = 1) where TSelf : IIndicator<TSelf, TSample, TValue> where TValue : ISubtractionOperators<TValue, TValue, TValue>, IDivisionOperators<TValue, TValue, TValue>
Parameters
sourceIIndicator<TSelf, TSample, TValue>The source indicator (e.g. a price).
lagintHow many samples back to compare against. Defaults to 1.
Returns
- CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue>
Type Parameters
TSelfTSampleTValue