dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
CandlePrice Struct Referencefinal

Price type attribute of CandleSymbol defines the price used to build the candles. More...

#include <CandlePrice.hpp>

Inheritance diagram for CandlePrice:

Public Member Functions

std::string changeAttributeForSymbol (StringParam symbol) const override
 Returns candle event symbol string with this candle price type set.
std::string toString () const
 Returns string representation of this candle price type.

Static Public Member Functions

static std::reference_wrapper< const CandlePrice > parse (StringParam s)
 Parses string representation of a candle price type into an object.
static std::reference_wrapper< const CandlePrice > getAttributeForSymbol (StringParam symbol)
 Returns the candle price type of the given candle symbol string.
static std::string normalizeAttributeForSymbol (StringParam symbol)
 Returns candle symbol string with the normalized representation of the candle price type attribute.

Static Public Attributes

static const CandlePrice LAST {"last"}
 Last trading price.
static const CandlePrice BID {"bid"}
 Quote bid price.
static const CandlePrice ASK {"ask"}
 Quote ask price.
static const CandlePrice MARK {"mark"}
 Market price defined as average between quote bid and ask prices.
static const CandlePrice SETTLEMENT {"s"}
 Official settlement price that is defined by exchange or last trading price otherwise.
static const CandlePrice DEFAULT {"last"}
 The default price type is CandlePrice::LAST.
static constexpr char ATTRIBUTE_KEY [] = "price"
 The attribute key that is used to store the value of CandlePrice in a symbol string using methods of MarketEventSymbols class.
static const ConstantMap< std::string_view, CandlePrice > BY_STRING {CANDLE_PRICES_BY_STRING}
 The elements by their string representations (constant-initialized, so it can be used in the dynamic initialization and the destruction of global variables).
static const std::span< const std::reference_wrapper< const CandlePrice > > VALUES {CANDLE_PRICES}
 All elements (constant-initialized, so the initializers of global variables can use it).

Detailed Description

Price type attribute of CandleSymbol defines the price used to build the candles.

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

Member Function Documentation

◆ changeAttributeForSymbol()

std::string CandlePrice::changeAttributeForSymbol ( StringParam symbol) const
overridevirtual

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

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

Implements CandleSymbolAttribute.

◆ getAttributeForSymbol()

std::reference_wrapper< const CandlePrice > CandlePrice::getAttributeForSymbol ( StringParam symbol)
static

Returns the candle price type of the given candle symbol string.

The result is CandlePrice::DEFAULT if the symbol does not have a candle price type attribute.

Parameters
symbolThe candle symbol string.
Returns
candle price type of the given candle symbol string.

References ATTRIBUTE_KEY.

◆ normalizeAttributeForSymbol()

std::string CandlePrice::normalizeAttributeForSymbol ( StringParam symbol)
static

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

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

References ATTRIBUTE_KEY, and DEFAULT.

◆ parse()

std::reference_wrapper< const CandlePrice > CandlePrice::parse ( StringParam s)
static

Parses string representation of a candle price type into an object.

Any string returned by CandlePrice::toString() can be parsed, and a case is ignored for parsing.

Parameters
sThe string representation of a candle price type.
Returns
The candle price type (reference).
Exceptions
InvalidArgumentExceptionif the argument is empty or invalid

◆ toString()

std::string CandlePrice::toString ( ) const

Returns string representation of this candle price type.

The string representation of a candle price type is a lower case string that corresponds to its name. For example, CandlePrice::LAST is represented as "last".

Returns
string representation of this candle price type.

Member Data Documentation

◆ ATTRIBUTE_KEY

char CandlePrice::ATTRIBUTE_KEY[] = "price"
staticconstexpr

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

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

Referenced by getAttributeForSymbol(), and normalizeAttributeForSymbol().

◆ SETTLEMENT

const CandlePrice CandlePrice::SETTLEMENT {"s"}
staticconstinit

Official settlement price that is defined by exchange or last trading price otherwise.

It updates based on all PriceType values: PriceType::INDICATIVE, PriceType::PRELIMINARY, and PriceType::FINAL}.