Table of Contents

Class VolumeFilter

Namespace
ATAS.Indicators
Assembly
ATAS.Indicators.dll

A volume threshold that can be set either in instrument volume units or in money (PLAT-5080).

Not in ATAS 8.0.15 yet: available from the next version.

public sealed class VolumeFilter : Filter<decimal, VolumeFilter>, IFilterValue, IFilter
Inheritance
object
VolumeFilter
Implements
Inherited Members
Extension Methods

Remarks

Value always holds the threshold in volume units. In money mode it is kept untouched and serves as the fallback: when no exchange rate is known and when an older platform version, which only knows Filter, loads the template - it reads the same JSON object, ignores the money fields and keeps working with the volume threshold.

A money threshold is compared with each trade at the trade's own price, so it keeps its meaning while the price of the instrument moves.

Constructors

VolumeFilter()

Initializes a new instance of the VolumeFilter class with default settings.

public VolumeFilter()

VolumeFilter(bool, bool)

Initializes a new instance of the VolumeFilter class.

public VolumeFilter(bool enableVisible, bool asScalar = false)

Parameters

enableVisible bool

A value indicating whether the filter's Enabled property is visible.

asScalar bool

A value indicating whether the filter is stored as a bare value while it is set in volume units.

Fields

InstrumentCurrencyUnitKey

UnitKey of money in the instrument's own currency (no exchange rate).

public const string InstrumentCurrencyUnitKey = "Instrument"

Field Value

string

VolumeUnitKey

UnitKey of the volume unit.

public const string VolumeUnitKey = "Volume"

Field Value

string

Properties

Amount

Threshold in money, used when Unit is Money.

[Browsable(false)]
public decimal Amount { get; set; }

Property Value

decimal

Currency

Currency of Amount; null means the instrument's own currency.

[Browsable(false)]
public string? Currency { get; set; }

Property Value

string

DisplayValue

Threshold in the current unit: Amount in money mode, otherwise Value. Bound by editors.

[Browsable(false)]
public decimal DisplayValue { get; set; }

Property Value

decimal

IsMoney

True when the threshold is set in money.

[Browsable(false)]
public bool IsMoney { get; }

Property Value

bool

MoneyScalar

The money part of the threshold as one invariant scalar, for indicators whose threshold was persisted as a bare number (PLAT-5080): "50000 EUR", "50000" for the instrument currency, null in volume mode. Such an indicator keeps persisting Value under the old property name and this text in a new one, so older versions read the volume threshold and skip the text. Setting it does not convert anything.

[Browsable(false)]
public string? MoneyScalar { get; set; }

Property Value

string

Unit

Unit the threshold is set in.

[Browsable(false)]
public VolumeFilterUnit Unit { get; set; }

Property Value

VolumeFilterUnit

UnitKey

Unit selector value for editors: VolumeUnitKey, InstrumentCurrencyUnitKey or a currency code. Switching from volume to money converts the threshold at the reference price when the filter is bound to a valuation.

[Browsable(false)]
public string UnitKey { get; set; }

Property Value

string

Valuation

Valuation of the instrument the filter is applied to. Bound by the host (indicators get it bound automatically); used when no valuation is passed explicitly and by editors to convert the threshold between units.

[Browsable(false)]
public IVolumeValuation? Valuation { get; set; }

Property Value

IVolumeValuation

Methods

Clone()

Creates a copy of the filter with its value, its enabled state, the unit, the money amount and the currency.

public override object Clone()

Returns

object

The copy.

Compare(decimal, decimal, IVolumeValuation?)

Compares a traded volume with the threshold.

public int Compare(decimal volume, decimal price, IVolumeValuation? valuation = null)

Parameters

volume decimal

Traded volume in instrument units.

price decimal

Trade price; used in money mode.

valuation IVolumeValuation

Valuation of the instrument; the bound Valuation when null.

Returns

int

Less than zero when the volume is below the threshold, zero when equal, greater than zero when above.

Equals(object?)

Determines whether the object is a filter with the same value, enabled state, unit, money amount and currency.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with.

Returns

bool

true when the filters are equal.

FormatThreshold()

Returns the threshold as text in its current unit, e.g. "100" or "€50,000.00".

public string FormatThreshold()

Returns

string

GetHashCode()

Returns a hash code consistent with Equals(object?).

public override int GetHashCode()

Returns

int

The hash code.

GetStringValue()

Added in ATAS 8.0.15.

public override string GetStringValue()

Returns

string

The string representation of the value.

GetUnitOptions()

Returns the units offered by editors: volume, the instrument currency and the display currencies.

public static IReadOnlyList<VolumeFilterUnitOption> GetUnitOptions()

Returns

IReadOnlyList<VolumeFilterUnitOption>

GetVolumeThreshold(decimal, IVolumeValuation?)

Returns the threshold in volume units at a price: Value in volume mode or when no rate is known, the volume worth Amount at price in money mode.

public decimal GetVolumeThreshold(decimal price, IVolumeValuation? valuation = null)

Parameters

price decimal
valuation IVolumeValuation

Returns

decimal

The threshold; decimal.MaxValue when the price does not allow the conversion (zero price).

HasThreshold(IVolumeValuation?)

True when the threshold is not zero in the unit it is applied in (a zero maximum usually means "no limit").

public bool HasThreshold(IVolumeValuation? valuation = null)

Parameters

valuation IVolumeValuation

Returns

bool

IsMoneyApplied(IVolumeValuation?)

True when the threshold is compared in money: money mode with a known exchange rate. In money mode without a rate the filter falls back to the volume threshold.

public bool IsMoneyApplied(IVolumeValuation? valuation = null)

Parameters

valuation IVolumeValuation

Returns

bool

TryGetMoneyFactor(IVolumeValuation?, out VolumeValueFactor)

Gets the factor converting volumes into money of the filter currency.

public bool TryGetMoneyFactor(IVolumeValuation? valuation, out VolumeValueFactor factor)

Parameters

valuation IVolumeValuation

Valuation of the instrument; the bound Valuation when null.

factor VolumeValueFactor

The factor when available.

Returns

bool

False in volume mode, or when the instrument cannot be valued in the filter currency.