dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches

Symbol that should be used with DXFeedSubscription class to subscribe for Candle events. More...

#include <CandleSymbol.hpp>

Public Member Functions

const std::string & getBaseSymbol () const &noexcept
 Returns base market symbol without attributes.
const std::optional< CandleExchange > & getExchange () const &noexcept
 Returns exchange attribute of this symbol.
const std::optional< CandlePrice > & getPrice () const &noexcept
 Returns the price type attribute of this symbol.
const std::optional< CandleSession > & getSession () const &noexcept
 Returns the session attribute of this symbol.
const std::optional< CandlePeriod > & getPeriod () const &noexcept
 Returns the aggregation period of this symbol.
const std::optional< CandleAlignment > & getAlignment () const &noexcept
 Returns alignment attribute of this symbol.
const std::optional< CandlePriceLevel > & getPriceLevel () const &noexcept
 Returns the price level attribute of this symbol.
const std::optional< CandleDataType > & getDataType () const &noexcept
 Returns the data type attribute of this symbol.
const std::string & toString () const &noexcept
 Returns string representation of this symbol.
virtual void * toGraal () const
 Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).

Static Public Member Functions

static CandleSymbol NUL ()
 Returns the candle symbol "<null>".
static void freeGraal (void *graalNative)
 Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
static CandleSymbol fromGraal (void *graalNative)
 Creates an object of the current type and fills it with data from the dxFeed Graal SDK structure.
static CandleSymbol valueOf (StringParam symbol)
 Converts the given string symbol into the candle symbol object.
static CandleSymbol valueOf (StringParam symbol, const CandleSymbolAttributeVariant &attribute)
 Converts the given string symbol into the candle symbol object with the specified attribute set.
template<typename CandleSymbolAttributeIt>
static CandleSymbol valueOf (StringParam symbol, CandleSymbolAttributeIt begin, CandleSymbolAttributeIt end)
 Converts the given string symbol into the candle symbol object with the specified attribute set (iterators).
static CandleSymbol valueOf (StringParam symbol, std::initializer_list< CandleSymbolAttributeVariant > attributes)
 Converts the given string symbol into the candle symbol object with the specified attributes set (initializer list).
template<typename CandleSymbolAttributesCollection>
requires requires(CandleSymbolAttributesCollection attributes) { { std::begin(attributes) }; { std::end(attributes) }; }
static CandleSymbol valueOf (StringParam symbol, CandleSymbolAttributesCollection &&attributes)
 Converts the given string symbol into the candle symbol object with the specified attributes set.

Detailed Description

Symbol that should be used with DXFeedSubscription class to subscribe for Candle events.

DXFeedSubscription also accepts a string representation of the candle symbol for subscription.

String representation

The string representation of the candle symbol consist of a baseSymbol followed by an optional '&' with an exchange code letter and followed by an optional list of comma-separated key=value pairs in curly braces:

<baseSymbol> [ '&' <exchange> ] [ '{' <key1>=<value1> [ ',' <key2>=<value2> ] ... '}' ]

Properties of the candle symbol correspond to the keys in the string representation in the following way:

  • Empty key corresponds to period — aggregation period of this symbol. The period value is composed of an optional value which defaults to 1 when not specified, followed by a type string which is defined by one of the CandleType values and can be abbreviated to first letters. For example, a daily candle of "IBM" base symbol can be specified as "IBM{=d}" and 15 minute candle on it as "IBM{=15m}". The shortest possible abbreviation for CandleType::MONTH is "mo", so the monthly candle can be specified as "IBM{=mo}". When a period is not specified, then the CandlePeriod::TICK aggregation period is assumed as default. Note that tick aggregation may not be available on the demo system, which is limited to a subset of symbols and aggregation periods.
  • "price" key corresponds to price — price type attribute of this symbol. The CandlePrice defines possible values with CandlePrice::LAST being default. For legacy backwards-compatibility purposes, most of the price values cannot be abbreviated, so a one-minute candle of "EUR/USD" bid price shall be specified with "EUR/USD{=m,price=bid}" candle symbol string. However, the CandlePrice::SETTLEMENT can be abbreviated to "s", so a daily candle on "/ES" futures settlement prices can be specified with "/ES{=d,price=s}" string.
  • "tho" key with a value of "true" corresponds to session set to CandleSession::REGULAR which limits the candle to trading hours only, so a 133 tick candles on "GOOG" base symbol collected over trading hours only can be specified with "GOOG{=133t,tho=true}" string. Note that the default daily candles for US equities are special for historical reasons and correspond to the way US equity exchange report their daily summary data. The volume of the US equity default daily candle corresponds to the total daily traded volume, while open, high, low, and close correspond to the regular trading hours only.
  • "a" key corresponds to alignment — alignment attribute of this symbol. The CandleAlignment defines possible values with CandleAlignment::MIDNIGHT being default. The alignment values can be abbreviated to the first letter. So, a 1 hour candle on a symbol "AAPL" that starts at the regular trading session at 9:30 am ET can be specified with "AAPL{=h,a=s,tho=true}". Contrast that to the "AAPL{=h,tho=true}" candle that is aligned at midnight and thus starts at 9:00 am.
  • "pl" key corresponds to price level — price level attribute of this symbol. The CandlePriceLevel defines additional axis to split candles within particular price corridor in addition to CandlePeriod attribute with the default value NaN. So a one-minute candles of "AAPL" with price level 0.1 shall be specified with "AAPL{=m,pl=0.1}".
  • "dt" key corresponds to data type — data type attribute of this symbol. The CandleDataType defines which types of data are used to build the candles, with CandleDataType::UNDEFINED being default. Any string is a valid data type, and its value is case-sensitive, so one-minute candles of "AAPL" built from the extended trading hours data shall be specified with "AAPL{=m,dt=eth}".

Keys in the candle symbol are case-sensitive, while values (except the data type) are not. The CandleSymbol::valueOf() method parses any valid string representation into a candle symbol object. The result of the candle symbol CandleSymbol::toString() method is always normalized: keys are ordered lexicographically, values (except the data type) are in lower-case and are abbreviated to their shortest possible form.

The page Candle symbols lists the attributes, examples and the typical mistakes.

Member Function Documentation

◆ freeGraal()

void CandleSymbol::freeGraal ( void * graalNative)
static

Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).

Parameters
graalNativeThe pointer to the dxFeed Graal SDK structure.
Exceptions
InvalidArgumentException

Referenced by SymbolWrapper::freeGraal().

◆ fromGraal()

CandleSymbol CandleSymbol::fromGraal ( void * graalNative)
static

Creates an object of the current type and fills it with data from the dxFeed Graal SDK structure.

Parameters
graalNativeThe pointer to the dxFeed Graal SDK structure.
Returns
The object of the current type.
Exceptions
InvalidArgumentException

Referenced by SymbolWrapper::fromGraal().

◆ getAlignment()

const std::optional< CandleAlignment > & CandleSymbol::getAlignment ( ) const &
noexcept

Returns alignment attribute of this symbol.

Returns
alignment attribute of this symbol.

◆ getBaseSymbol()

const std::string & CandleSymbol::getBaseSymbol ( ) const &
noexcept

Returns base market symbol without attributes.

Returns
base market symbol without attributes.

◆ getDataType()

const std::optional< CandleDataType > & CandleSymbol::getDataType ( ) const &
noexcept

Returns the data type attribute of this symbol.

Returns
data type attribute of this symbol.

◆ getExchange()

const std::optional< CandleExchange > & CandleSymbol::getExchange ( ) const &
noexcept

Returns exchange attribute of this symbol.

Returns
exchange attribute of this symbol.

◆ getPeriod()

const std::optional< CandlePeriod > & CandleSymbol::getPeriod ( ) const &
noexcept

Returns the aggregation period of this symbol.

Returns
aggregation period of this symbol.

◆ getPrice()

const std::optional< CandlePrice > & CandleSymbol::getPrice ( ) const &
noexcept

Returns the price type attribute of this symbol.

Returns
price type attribute of this symbol.

◆ getPriceLevel()

const std::optional< CandlePriceLevel > & CandleSymbol::getPriceLevel ( ) const &
noexcept

Returns the price level attribute of this symbol.

Returns
price level attribute of this symbol.

◆ getSession()

const std::optional< CandleSession > & CandleSymbol::getSession ( ) const &
noexcept

Returns the session attribute of this symbol.

Returns
session attribute of this symbol.

◆ toGraal()

void * CandleSymbol::toGraal ( ) const
virtual

Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).

Fills the dxFeed Graal SDK structure's fields by the data of the current entity (recursively if necessary). Returns the pointer to the filled structure.

Returns
The pointer to the filled dxFeed Graal SDK structure

◆ toString()

const std::string & CandleSymbol::toString ( ) const &
noexcept

Returns string representation of this symbol.

The string representation can be transformed back into a symbol object using the CandleSymbol::valueOf() method.

Returns
string representation of this symbol.

◆ valueOf() [1/5]

CandleSymbol CandleSymbol::valueOf ( StringParam symbol)
static

Converts the given string symbol into the candle symbol object.

A string without a period (it gives tick candles) or with a period of the type M or PR gets a warning through ErrorManager, once per string, see Candle symbols. The symbol is created anyway.

Parameters
symbolThe string symbol.
Returns
The candle symbol object.
Exceptions
InvalidArgumentExceptionif the string cannot be parsed.

◆ valueOf() [2/5]

template<typename CandleSymbolAttributeIt>
CandleSymbol CandleSymbol::valueOf ( StringParam symbol,
CandleSymbolAttributeIt begin,
CandleSymbolAttributeIt end )
inlinestatic

Converts the given string symbol into the candle symbol object with the specified attribute set (iterators).

Template Parameters
CandleSymbolAttributeItThe attribute iterator type.
Parameters
symbolThe string symbol.
beginThe beginning of the collection of attributes.
endThe end of the collection of attributes.
Returns

◆ valueOf() [3/5]

template<typename CandleSymbolAttributesCollection>
requires requires(CandleSymbolAttributesCollection attributes) { { std::begin(attributes) }; { std::end(attributes) }; }
CandleSymbol CandleSymbol::valueOf ( StringParam symbol,
CandleSymbolAttributesCollection && attributes )
inlinestatic

Converts the given string symbol into the candle symbol object with the specified attributes set.

Template Parameters
CandleSymbolAttributesCollectionThe collection of attributes type.
Parameters
symbolThe string symbol.
attributesMore attributes to set.
Returns
The candle symbol object.

◆ valueOf() [4/5]

CandleSymbol CandleSymbol::valueOf ( StringParam symbol,
const CandleSymbolAttributeVariant & attribute )
static

Converts the given string symbol into the candle symbol object with the specified attribute set.

Parameters
symbolThe string symbol.
attributeThe attribute to set.
Returns
The candle symbol object.

◆ valueOf() [5/5]

CandleSymbol CandleSymbol::valueOf ( StringParam symbol,
std::initializer_list< CandleSymbolAttributeVariant > attributes )
static

Converts the given string symbol into the candle symbol object with the specified attributes set (initializer list).

Parameters
symbolThe string symbol.
attributesMore attributes to set.
Returns
The candle symbol object.