dxFeed Graal CXX API
Loading...
Searching...
No Matches
dxfcpp::Trade Class Referencefinal

Trade event is a snapshot of the price and size of the last trade during regular trading hours and an overall day volume and day turnover. More...

#include <Trade.hpp>

+ Inheritance diagram for dxfcpp::Trade:

Public Types

using Ptr = std::shared_ptr<Trade>
 The alias to a type of shared pointer to the Trade object.
 
using Unique = std::unique_ptr<Trade>
 The alias to a type of unique pointer to the Trade object.
 
- Public Types inherited from dxfcpp::MarketEvent
using Ptr = std::shared_ptr<MarketEvent>
 The alias to a type of shared pointer to the MarketEvent object.
 
- Public Types inherited from dxfcpp::EventTypeWithSymbol< std::string >
using Ptr
 The alias to a type of shared pointer to the EventTypeWithSymbol's child object.
 
- Public Types inherited from dxfcpp::EventType
using Ptr = std::shared_ptr<EventType>
 The alias to a type of shared pointer to the EventType object.
 
- Public Types inherited from dxfcpp::SharedEntity
using Ptr = std::shared_ptr<SharedEntity>
 The alias to a type of shared pointer to the SharedEntity object.
 
- Public Types inherited from dxfcpp::LastingEvent
using Ptr = std::shared_ptr<LastingEvent>
 The alias to a type of shared pointer to the LastingEvent object.
 

Public Member Functions

voidtoGraal () const noexcept override
 Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
 
 Trade () noexcept=default
 Creates new trade event with default values.
 
 Trade (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 dxfcpp::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) noexcept
 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 DirectiongetTickDirection () 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 dxfcpp::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 dxfcpp::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 dxfcpp::Entity
virtual ~Entity () noexcept=default
 The default virtual d-tor.
 

Static Public Member Functions

static void freeGraal (void *graalNative) noexcept
 Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
 

Static Public Attributes

static const EventTypeEnumTYPE = EventTypeEnum::TRADE
 Type identifier and additional information about the current event class.
 
- Static Public Attributes inherited from dxfcpp::TradeBase
static constexpr std::uint32_t MAX_SEQUENCE = (1U << 22U) - 1U
 Maximum allowed sequence value.
 

Additional Inherited Members

- Protected Member Functions inherited from dxfcpp::MarketEvent
 MarketEvent (std::string eventSymbol) noexcept
 Protected constructor for concrete implementation classes that initializes eventSymbol property.
 

Detailed Description

Trade event is a snapshot of the price and size of the last trade during regular trading hours and an overall day volume and day turnover.

It represents the most recent information that is available about the regular last trade on the market at any given moment of time.

Trading sessions

The Trade event defines last trade price as officially defined by the corresponding exchange for its regular trading hours (RTH). It also include an official exchange dayVolume and dayTurnover for the whole trading day identified by dayId. So, Trade event captures all the official numbers that are typically reported by exchange.

Trades that happen in extended trading hours (ETH, pre-market and post-market trading sessions), which are typically defined for stocks and ETFs, do not update last trade time, exchangeCode, price, change, size, and tickDirection in the Trade event, but they do update dayVolume and dayTurnover.

During extended trading hours a TradeETH event is generated on each trade with its extendedTradingHours property set to true.

Volume and Turnover

The volume and turnover are included into the Trade event instead of Summary event, because both volume and turnover typically update with each trade. The dayId field identifies current trading day for which volume and turnover statistics are computed. This solution avoids generation of multiple events on each trade during regular trading hours. Summary event is generated during the trading day only when new highs or lows are reached or other properties change.

Note that one can compute volume-weighted average price (VWAP) for a day by this formula:
vwap = dayTurnover / dayVolume;

Daily reset

Daily reset procedure that happens on a schedule during non-trading hours resets Trade 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 RTH trade until the next RTH trade happens.

Implementation details

This event is implemented on top of QDS records Trade and Trade&X for regional exchange trades. Regional records do not explicitly store a field for exchangeCode property.

Constructor & Destructor Documentation

◆ Trade()

dxfcpp::Trade::Trade ( std::string eventSymbol)
inlineexplicitnoexcept

Creates new trade event with the specified event symbol.

Parameters
eventSymbolThe event symbol.

Member Function Documentation

◆ freeGraal()

void dxfcpp::Trade::freeGraal ( void * graalNative)
staticnoexcept

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

Parameters
graalNativeThe pointer to the dxFeed Graal SDK structure.

◆ toGraal()

void * dxfcpp::Trade::toGraal ( ) const
overridevirtualnoexcept

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

Implements dxfcpp::EventType.

◆ toString()

std::string dxfcpp::Trade::toString ( ) const
overridevirtualnoexcept

Returns a string representation of the current object.

Returns
a string representation

Reimplemented from dxfcpp::EventType.