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

Candle price level attribute of CandleSymbol defines how candles shall be aggregated in respect to price interval. More...

#include <CandlePriceLevel.hpp>

+ Inheritance diagram for dxfcpp::CandlePriceLevel:

Public Member Functions

double getValue () const noexcept
 Returns price level value.
 
std::string toString () const noexcept
 Returns string representation of this price level.
 
std::string changeAttributeForSymbol (const std::string &symbol) const noexcept override
 Returns candle event symbol string with this candle price level set.
 

Static Public Member Functions

static std::optional< CandlePriceLevelparse (const std::string &s) noexcept
 Parses string representation of candle price level into object.
 
static std::optional< CandlePriceLevelvalueOf (double value) noexcept
 Returns candle price level with the given value.
 
static std::optional< CandlePriceLevelgetAttributeForSymbol (const std::string &symbol) noexcept
 Returns candle price level 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 price level attribute.
 

Static Public Attributes

static const CandlePriceLevel DEFAULT {math::NaN}
 Default price level corresponds to NaN (std::numeric_limits<double>::quiet_NaN())
 
static const std::string ATTRIBUTE_KEY {"pl"}
 The attribute key that is used to store the value of CandlePriceLevel in a symbol string using methods of MarketEventSymbols class.
 

Detailed Description

Candle price level attribute of CandleSymbol defines how candles shall be aggregated in respect to price interval.

The negative or infinite values of price interval are treated as exceptional.

  • Price interval may be equal to zero. It means every unique price creates a particular candle to aggregate all events with this price for the chosen CandlePeriod.
  • Non-zero price level creates sequence of intervals starting from 0: ...,[-pl;0),[0;pl),[pl;2*pl),...,[n*pl,n*pl+pl). Events aggregated by chosen CandlePeriod and price intervals.

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 CandlePriceLevel::ATTRIBUTE_KEY constant. The value that this key shall be set to is equal to the corresponding CandlePriceLevel::toString()

Member Function Documentation

◆ changeAttributeForSymbol()

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

Returns candle event symbol string with this candle price level set.

Parameters
symboloriginal candle event symbol.
Returns
candle event symbol string with this candle price level set.

Implements dxfcpp::CandleSymbolAttribute.

◆ getAttributeForSymbol()

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

Returns candle price level of the given candle symbol string.

The result is CandlePriceLevel::DEFAULT if the symbol does not have candle price level attribute.

Parameters
symbolcandle symbol string.
Returns
candle price level of the given candle symbol string or std::nullopt if there is no supported attribute's

◆ getValue()

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

Returns price level value.

For example, the value of 1 represents [0;1), [1;2) and so on intervals to build candles.

Returns
price level value.

◆ normalizeAttributeForSymbol()

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

Returns candle symbol string with the normalized representation of the candle price level attribute.

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

◆ parse()

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

Parses string representation of candle price level into object.

Any string that was returned by CandlePriceLevel::toString() can be parsed and case is ignored for parsing.

Parameters
sstring representation of candle price level.
Returns
candle price level or std::nullopt if the string representation is invalid or value is invalid

◆ toString()

std::string dxfcpp::CandlePriceLevel::toString ( ) const
inlinenoexcept

Returns string representation of this price level.

The string representation is composed of value. This string representation can be converted back into object with CandlePriceLevel::parse() method.

Returns
string representation of this price level.

◆ valueOf()

static std::optional< CandlePriceLevel > dxfcpp::CandlePriceLevel::valueOf ( double value)
inlinestaticnoexcept

Returns candle price level with the given value.

Parameters
valuecandle price level value.
Returns
candle price level with the given value and type or std::nullopt if value is invalid

Member Data Documentation

◆ ATTRIBUTE_KEY

const std::string dxfcpp::CandlePriceLevel::ATTRIBUTE_KEY {"pl"}
static

The attribute key that is used to store the value of CandlePriceLevel in a symbol string using methods of MarketEventSymbols class.

The value of this constant is "pl". The value that this key shall be set to is equal to the corresponding CandlePriceLevel::toString()