Class CandlePeriod
Period attribute of CandleSymbol defines aggregation period of the candles.
Aggregation period is defined as pair of a Value and Type.
For more details see Javadoc.
public class CandlePeriod : ICandleSymbolProperty
- Inheritance
-
CandlePeriod
- Implements
- Inherited Members
Fields
AttributeKey
The attribute key that is used to store the value of CandlePeriod in a symbol string using methods of MarketEventSymbols class. The value of this constant is an empty string, because this is the main attribute that every CandleSymbol must have. The value that this key shall be set to is equal to the corresponding ToString().
public const string AttributeKey = ""
Field Value
Day
Day aggregation where each candle represents a day.
public static readonly CandlePeriod Day
Field Value
Default
Default period is Tick.
public static readonly CandlePeriod Default
Field Value
Tick
Tick aggregation where each candle represents an individual tick.
public static readonly CandlePeriod Tick
Field Value
Properties
PeriodIntervalMillis
Gets aggregation period in milliseconds as closely as possible.
Certain aggregation types like Second and
Day span a specific number of milliseconds.
Month, OptExp and Year
are approximate. Candle period of
Tick, Volume, Price,
PriceMomentum and PriceRenko
is not defined and this method returns 0
.
The result of this method is equal to:
(long) (this.Type.PeriodIntervalMillis * this.Value)
public long PeriodIntervalMillis { get; }
Property Value
Type
Gets aggregation period type.
public CandleType Type { get; }
Property Value
Value
Gets aggregation period value.
For example, the value of 5
with
the candle type of Minute represents 5 minute
aggregation period.
public double Value { get; }
Property Value
Methods
ChangeAttributeForSymbol(string?)
Returns candle event symbol string with this aggregation period set.
public string? ChangeAttributeForSymbol(string? symbol)
Parameters
symbol
stringThe original candle event symbol.
Returns
- string
The candle event symbol string with this aggregation period set.
CheckInAttribute(CandleSymbol)
Internal method that initializes attribute in the candle symbol.
public void CheckInAttribute(CandleSymbol candleSymbol)
Parameters
candleSymbol
CandleSymbolThe candle symbol.
Exceptions
- InvalidOperationException
If used outside of internal initialization logic.
Equals(object?)
Determines whether the specified object is equal to the current object. The same aggregation period has the same Value} and Type.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
- bool
true
if the specified object is equal to the current object; otherwise,false
.
GetAttributeForSymbol(string?)
Gets candle period of the given candle symbol string. The result is Default if the symbol does not have candle period attribute.
public static CandlePeriod GetAttributeForSymbol(string? symbol)
Parameters
symbol
stringThe candle symbol string.
Returns
- CandlePeriod
The candle period of the given candle symbol string.
GetHashCode()
Returns a hash code value for this object.
public override int GetHashCode()
Returns
- int
A hash code value for this object.
NormalizeAttributeForSymbol(string?)
Returns candle symbol string with the normalized representation of the candle period attribute.
public static string? NormalizeAttributeForSymbol(string? symbol)
Parameters
symbol
stringThe candle symbol string.
Returns
- string
The candle symbol string with the normalized representation of the the candle period attribute.
Parse(string)
Parses string representation of aggregation period into object. Any string that was returned by ToString() can be parsed. This method is flexible in the way candle types can be specified. See Parse(string) for details.
public static CandlePeriod Parse(string s)
Parameters
s
stringstring representation of aggregation period.
Returns
- CandlePeriod
aggregation period object.
Exceptions
- ArgumentNullException
If input string is null.
- FormatException
If input string does not represent a number in a valid format.
- OverflowException
If input string represents a number that is less than MinValue or greater than MaxValue.
ToString()
Returns string representation of this aggregation period.
The string representation is composed of value and type string.
For example, 5 minute aggregation is represented as "5m"
.
The value of 1
is omitted in the string representation, so
Day (one day) is represented as "d"
.
This string representation can be converted back into object
with Parse(string) method.
public override string ToString()
Returns
- string
The string representation.
ValueOf(double, CandleType)
Returns candle period with the given value and type.
public static CandlePeriod ValueOf(double value, CandleType type)
Parameters
value
doubleThe value candle period value.
type
CandleTypeThe candle period type.
Returns
- CandlePeriod
The candle period with the given value and type.