dxFeed Graal CXX API v5.0.0
Loading...
Searching...
No Matches
MarketEventSymbols Struct Reference

Helper class to compose and parse symbols for market events. More...

#include <MarketEventSymbols.hpp>

Static Public Member Functions

static bool hasExchangeCode (const StringLike &symbol) noexcept
 Returns true if the specified symbol has the exchange code specification.
 
static char getExchangeCode (const StringLike &symbol) noexcept
 Returns exchange code of the specified symbol or ‘’\0'` if none is defined.
 
static std::string changeExchangeCode (const StringLike &symbol, char exchangeCode) noexcept
 Changes exchange code of the specified symbol or removes it if the new exchange code is ‘’\0'`.
 
static std::string getBaseSymbol (const StringLike &symbol) noexcept
 Returns base symbol without exchange code and attributes.
 
static std::string changeBaseSymbol (const StringLike &symbol, const StringLike &baseSymbol) noexcept
 Changes base symbol while leaving exchange code and attributes intact.
 
static std::optional< std::string > getAttributeStringByKey (const StringLike &symbol, const StringLike &key) noexcept
 Returns value of the attribute with the specified key.
 
static std::string changeAttributeStringByKey (const StringLike &symbol, const StringLike &key, const StringLike &value) noexcept
 Changes the value of one attribute value while leaving exchange code and other attributes intact.
 
static std::string removeAttributeStringByKey (const StringLike &symbol, const StringLike &key) noexcept
 Removes one attribute with the specified key while leaving exchange code and other attributes intact.
 

Detailed Description

Helper class to compose and parse symbols for market events.

Regional symbols

Regional symbol subscription receives events only from a designated exchange, marketplace, or venue instead of receiving composite events from all venues (by default). Regional symbol is composed of a base symbol, ampersand character ('&'), and an exchange code character. For example,

  • "SPY" is the symbol for composite events for SPDR S&P 500 ETF from all exchanges,
  • "SPY&amp;N" is the symbol for event for SPDR S&P 500 ETF that originates only from the NYSE marketplace.

Symbol attributes

Market event symbols can have a number of attributes attached to them in curly braces with <key>=<value> paris separated by commas. For example,

  • "SPY{price=bid}" is the market symbol "SPY" with an attribute key "price" set to value "bid".
  • "SPY(=5m,tho=true}" is the market symbol "SPY" with two attributes. One has an empty key and value "5m", while the other has key "tho" and value "true".

The methods in this class always maintain attribute keys in alphabetic order.

Member Function Documentation

◆ changeAttributeStringByKey()

static std::string MarketEventSymbols::changeAttributeStringByKey ( const StringLike & symbol,
const StringLike & key,
const StringLike & value )
inlinestaticnoexcept

Changes the value of one attribute value while leaving exchange code and other attributes intact.

Parameters
symbolold symbol.
keyattribute key.
valueattribute value.
Returns
new symbol with a key attribute with the specified value and everything else from the old symbol.

◆ changeBaseSymbol()

static std::string MarketEventSymbols::changeBaseSymbol ( const StringLike & symbol,
const StringLike & baseSymbol )
inlinestaticnoexcept

Changes base symbol while leaving exchange code and attributes intact.

Parameters
symbolold symbol.
baseSymbolnew base symbol.
Returns
new symbol with new base symbol and old symbol's exchange code and attributes.

◆ changeExchangeCode()

static std::string MarketEventSymbols::changeExchangeCode ( const StringLike & symbol,
char exchangeCode )
inlinestaticnoexcept

Changes exchange code of the specified symbol or removes it if the new exchange code is ‘’\0'`.

Parameters
symbolThe old symbol.
exchangeCodeThe new exchange code.
Returns
new symbol with the changed exchange code.

◆ getAttributeStringByKey()

static std::optional< std::string > MarketEventSymbols::getAttributeStringByKey ( const StringLike & symbol,
const StringLike & key )
inlinestaticnoexcept

Returns value of the attribute with the specified key.

The result is std::nullopt if the attribute with the specified key is not found.

Parameters
symbolsymbol.
keyattribute key.
Returns
value of the attribute with the specified key | std::nullopt if the attribute with the specified key is not found.

◆ getBaseSymbol()

static std::string MarketEventSymbols::getBaseSymbol ( const StringLike & symbol)
inlinestaticnoexcept

Returns base symbol without exchange code and attributes.

Parameters
symbolsymbol.
Returns
base symbol without exchange code and attributes.

◆ getExchangeCode()

static char MarketEventSymbols::getExchangeCode ( const StringLike & symbol)
inlinestaticnoexcept

Returns exchange code of the specified symbol or ‘’\0'` if none is defined.

Parameters
symbolThe symbol.
Returns
exchange code of the specified symbol or ‘’\0'` if none is defined.

Referenced by CandleExchange::getAttributeForSymbol().

◆ hasExchangeCode()

static bool MarketEventSymbols::hasExchangeCode ( const StringLike & symbol)
inlinestaticnoexcept

Returns true if the specified symbol has the exchange code specification.

Parameters
symbolThe symbol.
Returns
true if the specified symbol has the exchange code specification.

◆ removeAttributeStringByKey()

static std::string MarketEventSymbols::removeAttributeStringByKey ( const StringLike & symbol,
const StringLike & key )
inlinestaticnoexcept

Removes one attribute with the specified key while leaving exchange code and other attributes intact.

Parameters
symbolold symbol.
keyattribute key.
Returns
new symbol without the specified key and everything else from the old symbol.