dxFeed Graal CXX API
Loading...
Searching...
No Matches
dxfcpp::CandlePeriod Struct Reference

Period attribute of CandleSymbol defines aggregation period of the candles. More...

#include <CandlePeriod.hpp>

+ Inheritance diagram for dxfcpp::CandlePeriod:

Public Member Functions

std::int64_t getPeriodIntervalMillis () const noexcept
 Returns aggregation period in milliseconds as closely as possible.
 
std::string changeAttributeForSymbol (const std::string &symbol) const noexcept override
 Returns candle event symbol string with this aggregation period set.
 
double getValue () const noexcept
 Returns aggregation period value.
 
const CandleTypegetType () const &noexcept
 Returns aggregation period type.
 
const std::string & toString () const &noexcept
 Returns string representation of this aggregation period.
 

Static Public Member Functions

static std::optional< CandlePeriodparse (const std::string &s) noexcept
 Parses string representation of aggregation period into object.
 
static CandlePeriod valueOf (double value, const CandleType &type) noexcept
 Returns candle period with the given value and type.
 
static std::optional< CandlePeriodgetAttributeForSymbol (const std::string &symbol) noexcept
 Returns candle period of the given candle symbol string.
 
static DXFCPP_CXX20_CONSTEXPR_STRING std::string normalizeAttributeForSymbol (const std::string &symbol) noexcept
 Returns candle symbol string with the normalized representation of the candle period attribute.
 

Static Public Attributes

static const CandlePeriod TICK {1, CandleType::TICK}
 Tick aggregation where each candle represents an individual tick.
 
static const CandlePeriod DAY {1, CandleType::DAY}
 Day aggregation where each candle represents a day.
 
static const CandlePeriod DEFAULT = TICK
 Default period is CandlePeriod::TICK.
 
static const std::string ATTRIBUTE_KEY {}
 The attribute key that is used to store the value of CandlePeriod in a symbol string using methods of MarketEventSymbols class.
 

Detailed Description

Period attribute of CandleSymbol defines aggregation period of the candles.

Aggregation period is defined as pair of a value and type.

Implementation details

This attribute is encoded in a symbol string with MarketEventSymbols.getAttributeStringByKey, changeAttributeStringByKey, and removeAttributeStringByKey methods. The key to use with these methods is available via CandlePeriod::ATTRIBUTE_KEY constant. The value that this key shall be set to is equal to the corresponding CandlePeriod::toString() "CandlePeriod.toString()"

Member Function Documentation

◆ changeAttributeForSymbol()

std::string dxfcpp::CandlePeriod::changeAttributeForSymbol ( const std::string & symbol) const
inlineoverridevirtualnoexcept

Returns candle event symbol string with this aggregation period set.

Parameters
symboloriginal candle event symbol.
Returns
candle event symbol string with this aggregation period set.

Implements dxfcpp::CandleSymbolAttribute.

◆ getAttributeForSymbol()

static std::optional< CandlePeriod > dxfcpp::CandlePeriod::getAttributeForSymbol ( const std::string & symbol)
inlinestaticnoexcept

Returns candle period of the given candle symbol string.

The result is CandlePeriod::DEFAULT if the symbol does not have candle period attribute.

Parameters
symbolcandle symbol string.
Returns
candle period of the given candle symbol string or std::nullopt if parsing fails (if string representation is invalid)

◆ getPeriodIntervalMillis()

std::int64_t dxfcpp::CandlePeriod::getPeriodIntervalMillis ( ) const
inlinenoexcept

Returns aggregation period in milliseconds as closely as possible.

Certain aggregation types like SECOND and DAY span a specific number of milliseconds. CandleType::MONTH, CandleType::OPTEXP and CandleType::YEAR are approximate. Candle period of CandleType::TICK, CandleType::VOLUME, CandleType::PRICE, CandleType::PRICE_MOMENTUM and CandleType::PRICE_RENKO is not defined and this method returns 0. The result of this method is equal to static_cast<std::int64_t>(this->getType().getPeriodIntervalMillis() * this->getValue())

See also
CandleType::getPeriodIntervalMillis()
Returns
aggregation period in milliseconds.

◆ getType()

const CandleType & dxfcpp::CandlePeriod::getType ( ) const &
inlinenoexcept

Returns aggregation period type.

Returns
aggregation period type.

◆ getValue()

double dxfcpp::CandlePeriod::getValue ( ) const
inlinenoexcept

Returns aggregation period value.

For example, the value of 5 with the candle type of MINUTE represents 5 minute aggregation period.

Returns
aggregation period value.

◆ normalizeAttributeForSymbol()

static DXFCPP_CXX20_CONSTEXPR_STRING std::string dxfcpp::CandlePeriod::normalizeAttributeForSymbol ( const std::string & symbol)
inlinestaticnoexcept

Returns candle symbol string with the normalized representation of the candle period attribute.

Parameters
symbolcandle symbol string.
Returns
candle symbol string with the normalized representation of the the candle period attribute.

◆ parse()

static std::optional< CandlePeriod > dxfcpp::CandlePeriod::parse ( const std::string & s)
inlinestaticnoexcept

Parses string representation of aggregation period into object.

Any string that was returned by CandlePeriod::toString() can be parsed. This method is flexible in the way candle types can be specified. See CandleType::parse() for details.

Parameters
sThe string representation of aggregation period.
Returns
The aggregation period object or std::nullopt if parsing fails (if string representation is invalid)

◆ toString()

const std::string & dxfcpp::CandlePeriod::toString ( ) const &
inlinenoexcept

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 CandlePeriod::DAY (one day) is represented as "d". This string representation can be converted back into object with CandlePeriod::parse() method.

Returns
string representation of this aggregation period.

◆ valueOf()

static CandlePeriod dxfcpp::CandlePeriod::valueOf ( double value,
const CandleType & type )
inlinestaticnoexcept

Returns candle period with the given value and type.

Parameters
valuecandle period value.
typecandle period type.
Returns
candle period with the given value and type.

Member Data Documentation

◆ ATTRIBUTE_KEY

const std::string dxfcpp::CandlePeriod::ATTRIBUTE_KEY {}
static

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 CandlePeriod::toString()