dxFeed Graal CXX API
|
TradeETH event is a snapshot of the price and size of the last trade during extended trading hours and the extended trading hours day volume and day turnover. More...
#include <TradeETH.hpp>
Public Types | |
using | Ptr = std::shared_ptr<TradeETH> |
The alias to a type of shared pointer to the TradeETH object. | |
using | Unique = std::unique_ptr<TradeETH> |
The alias to a type of unique pointer to the TradeETH object. | |
Public Types inherited from MarketEvent | |
using | Ptr = std::shared_ptr<MarketEvent> |
The alias to a type of shared pointer to the MarketEvent object. | |
Public Types inherited from EventTypeWithSymbol< std::string > | |
using | Ptr |
The alias to a type of shared pointer to the EventTypeWithSymbol's child object. | |
Public Types inherited from EventType | |
using | Ptr = std::shared_ptr<EventType> |
The alias to a type of shared pointer to the EventType object. | |
Public Types inherited from SharedEntity | |
using | Ptr = std::shared_ptr<SharedEntity> |
The alias to a type of shared pointer to the SharedEntity object. | |
Public Types inherited from LastingEvent | |
using | Ptr = std::shared_ptr<LastingEvent> |
The alias to a type of shared pointer to the LastingEvent object. | |
Public Member Functions | |
void * | toGraal () const override |
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary). | |
TradeETH () noexcept=default | |
Creates new trade event with default values. | |
TradeETH (std::string eventSymbol) noexcept | |
Creates new trade event with the specified event symbol. | |
std::string | toString () const noexcept override |
Returns a string representation of the current object. | |
Public Member Functions inherited from TradeBase | |
TradeBase () noexcept=default | |
Creates new trade event with default values. | |
TradeBase (std::string eventSymbol) noexcept | |
Creates new trade event with the specified event symbol. | |
std::int64_t | getTimeSequence () const noexcept |
Returns time and sequence of last trade packaged into single long value. | |
void | setTimeSequence (std::int64_t timeSequence) noexcept |
Changes time and sequence of last trade. | |
std::int64_t | getTime () const noexcept |
Returns time of the last trade. | |
void | setTime (std::int64_t time) noexcept |
Changes time of the last trade. | |
std::int64_t | getTimeNanos () const noexcept |
Returns time of the last trade in nanoseconds. | |
void | setTimeNanos (std::int64_t timeNanos) noexcept |
Changes time of the last trade. | |
void | setTimeNanoPart (std::int32_t timeNanoPart) noexcept |
Changes microseconds and nanoseconds time part of the last trade. | |
std::int32_t | getTimeNanoPart () const noexcept |
Returns microseconds and nanoseconds time part of the last trade. | |
std::int32_t | getSequence () const noexcept |
Returns sequence number of the last trade to distinguish trades that have the same time. | |
void | setSequence (std::int32_t sequence) |
Changes sequence number of the last trade. | |
std::int16_t | getExchangeCode () const noexcept |
Returns exchange code of the last trade. | |
std::string | getExchangeCodeString () const noexcept |
Returns exchange code of last trade as UTF8 string. | |
void | setExchangeCode (char exchangeCode) noexcept |
Changes exchange code of the last trade. | |
void | setExchangeCode (std::int16_t exchangeCode) noexcept |
Changes exchange code of the last trade. | |
double | getPrice () const noexcept |
Returns price of the last trade. | |
void | setPrice (double price) noexcept |
Changes price of the last trade. | |
double | getSize () const noexcept |
Returns size of the last trade as floating number with fractions. | |
void | setSize (double size) noexcept |
Changes size of the last trade as floating number with fractions. | |
std::int32_t | getDayId () const noexcept |
Returns identifier of the current trading day. | |
void | setDayId (std::int32_t dayId) noexcept |
Changes identifier of the current trading day. | |
double | getDayVolume () const noexcept |
Returns total volume traded for a day as floating number with fractions. | |
void | setDayVolume (double dayVolume) noexcept |
Changes total volume traded for a day as floating number with fractions. | |
double | getDayTurnover () const noexcept |
Returns total turnover traded for a day. | |
void | setDayTurnover (double dayTurnover) noexcept |
Changes total turnover traded for a day. | |
const Direction & | getTickDirection () const &noexcept |
Returns tick direction of the last trade. | |
void | setTickDirection (const Direction &direction) noexcept |
Changes tick direction of the last trade. | |
bool | isExtendedTradingHours () const noexcept |
Returns whether last trade was in extended trading hours. | |
void | setExtendedTradingHours (bool extendedTradingHours) noexcept |
Changes whether last trade was in extended trading hours. | |
double | getChange () const noexcept |
Returns change of the last trade. | |
void | setChange (double change) noexcept |
Changes change of the last trade. | |
std::string | baseFieldsToString () const noexcept |
Returns string representation of this trade event's fields. | |
Public Member Functions inherited from MarketEvent | |
const std::string & | getEventSymbol () const &noexcept override |
Returns symbol of this event. | |
const std::optional< std::string > & | getEventSymbolOpt () const &noexcept override |
Returns symbol of this event. | |
void | setEventSymbol (const std::string &eventSymbol) noexcept override |
Changes symbol of this event. | |
std::int64_t | getEventTime () const noexcept override |
Returns time when event was created or zero when time is not available. | |
void | setEventTime (std::int64_t eventTime) noexcept override |
Changes event creation time. | |
Public Member Functions inherited from SharedEntity | |
template<typename T > | |
bool | is () const noexcept |
Checks that pointer to the current type could be converted to type T* In other words: whether type T belongs to the type hierarchy in which the current type resides. | |
template<typename T > | |
std::shared_ptr< T > | sharedAs () noexcept |
Returns a pointer to the current object wrapped in a smart pointer to type T. | |
template<typename T > | |
std::shared_ptr< T > | sharedAs () const noexcept |
Returns a pointer to the current object wrapped in a smart pointer to type T. | |
Public Member Functions inherited from Entity | |
virtual | ~Entity () noexcept=default |
The default virtual d-tor. | |
Static Public Member Functions | |
static Ptr | fromGraal (void *graalNative) |
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure. | |
static void | freeGraal (void *graalNative) |
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary). | |
Static Public Attributes | |
static const EventTypeEnum & | TYPE = EventTypeEnum::TRADE_ETH |
Type identifier and additional information about the current event class. | |
Static Public Attributes inherited from TradeBase | |
static constexpr std::uint32_t | MAX_SEQUENCE = (1U << 22U) - 1U |
Maximum allowed sequence value. | |
Additional Inherited Members | |
Protected Member Functions inherited from MarketEvent | |
MarketEvent (std::string eventSymbol) noexcept | |
Protected constructor for concrete implementation classes that initializes eventSymbol property. | |
TradeETH event is a snapshot of the price and size of the last trade during extended trading hours and the extended trading hours day volume and day turnover.
This event is defined only for symbols (typically stocks and ETFs) with a designated extended trading hours (ETH, pre market and post market trading sessions). It represents the most recent information that is available about ETH last trade on the market at any given moment of time.
The TradeETH event defines last trade price as officially defined by the corresponding exchange for its extended trading hours (ETH). It also includes dayVolume and dayTurnover for the extended trading hours only of the trading day identified by dayId. This event is not defined for symbols that has no concept of ETH.
When the first trade of regular trading hours (RTH) happens, then TradeETH event is generated with extendedTradingHours property set to false
. Afterwards, during RTH, TradeETH event is not updated and retains information about the last trade, volume and turnover of the pre market trading session.
When the first trade of extended trading hours (ETH) happens, then TradeETH event is generated with extendedTradingHours property set to true
. Afterwards, during ETH, TradeETH event is updated on each trade with the last trade information from post market trading session and total volume and turnover of the pre and post market trading session (excluding the volume and turnover of a regular trading session).
Note, that during pre- and post-market sessions, Trade event also updates, but only its dayVolume and dayTurnover properties change to reflect the overall official volume and turnover as reported by exchanges. During post market trading session, exchanges may correct their official RTH last trading price, which results in the update to Trade event.
Note that one can compute volume-weighted average price (VWAP) for extended trading hours by this formula:
vwap = dayTurnover / dayVolume;
Daily reset procedure that happens on a schedule during non-trading hours resets TradeETH dayVolume and dayTurnover to math::NaN and sets dayId to the next trading day in preparation to the next day's pre-market trading session (or for regular trading if there is no pre-market) while leaving all other properties intact. They reflect information about the last known ETH trade until the next ETH trade happens.
The most recent last trade price ("extended last price") in the market can be found by combining information from both Trade and TradeETH events using isExtendedTradingHours method to figure out which trading session had the most recent trade. The following piece of code finds the most recent last trade price from the given feed for a given symbol
, assuming there is a subscription for both Trade and TradeETH events for the given symbol
:
auto trade = feed->getLastEvent(Trade::create(symbol));
auto tradeEth = feed->getLastEvent(TradeETH::create(symbol));
double extLast = tradeEth->isExtendedTradingHours() ?
tradeEth->getPrice() : trade->getPrice();
Note, that the above code works correctly for symbols that has no concept of ETH, too, because in this case the DXFeed::getLastEvent() leaves default values in TradeETH event properties, which means that extendedTradingHours flag is false
and a regular Trade::getPrice() is used.
This event is implemented on top of QDS record TradeETH
and TradeETH&X
for regional exchange extended trade hours. extendedTradingHours property is internally represented as a last bit of the "Flags" field of the record. Regional records do not explicitly store a field for exchangeCode property.
|
inlineexplicitnoexcept |
Creates new trade event with the specified event symbol.
eventSymbol | The event symbol. |
|
static |
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
graalNative | The pointer to the dxFeed Graal SDK structure. |
|
static |
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
graalNative | The pointer to the dxFeed Graal SDK structure. |
std::invalid_argument |
|
overridevirtual |
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.
Implements EventType.
|
overridevirtualnoexcept |
Returns a string representation of the current object.
Reimplemented from EventType.