Table of Contents

Class Returns

Namespace
Virtufin.Base.Behavior
Assembly
Virtufin.Base.dll
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

source IIndicator<TSelf, TSample, TValue>

The source indicator (e.g. a price).

lag int

How many samples back to compare against. Defaults to 1.

Returns

CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue>

Type Parameters

TSelf
TSample
TValue

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

source IIndicator<TSelf, TSample, double>

The source indicator (e.g. a price).

lag int

How many samples back to compare against. Defaults to 1.

Returns

CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, double>, TSample, double, double, double>

Type Parameters

TSelf
TSample

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

source IIndicator<TSelf, TSample, TValue>

The source indicator (e.g. a price).

lag int

How many samples back to compare against.

log Func<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

TSelf
TSample
TValue

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

source IIndicator<TSelf, TSample, TValue>

The source indicator (e.g. a price).

lag int

How many samples back to compare against. Defaults to 1.

Returns

CombinedIndicator<TSelf, LagIndicator<TSelf, TSample, TValue>, TSample, TValue, TValue, TValue>

Type Parameters

TSelf
TSample
TValue