dxFeed Graal CXX API
Loading...
Searching...
No Matches
dxfcpp::OrderBase Class Reference

Base class for common fields of Order, AnalyticOrder and SpreadOrder events. More...

#include <OrderBase.hpp>

+ Inheritance diagram for dxfcpp::OrderBase:

Public Member Functions

 OrderBase () noexcept=default
 Creates new order event with default values.
 
 OrderBase (std::string eventSymbol) noexcept
 Creates new order event with the specified event symbol.
 
const OrderSourcegetSource () const &noexcept override
 Returns source of this event.
 
void setSource (const OrderSource &source) noexcept
 Changes source of this event.
 
std::int32_t getEventFlags () const noexcept override
 Returns transactional event flags.
 
EventFlagsMask getEventFlagsMask () const noexcept override
 Returns transactional event flags.
 
void setEventFlags (std::int32_t eventFlags) noexcept override
 Changes transactional event flags.
 
void setEventFlags (const EventFlagsMask &eventFlags) noexcept override
 Changes transactional event flags.
 
void setIndex (std::int64_t index) noexcept override
 Changes unique per-symbol index of this order.
 
std::int64_t getIndex () const noexcept override
 Returns unique per-symbol index of this order.
 
std::int64_t getTimeSequence () const noexcept
 Returns time and sequence of this order packaged into single long value.
 
void setTimeSequence (std::int64_t timeSequence) noexcept
 Changes time and sequence of this order.
 
std::int64_t getTime () const noexcept
 Returns time of this order.
 
void setTime (std::int64_t time) noexcept
 Changes time of this order.
 
void setTimeNanoPart (std::int32_t timeNanoPart) noexcept
 Changes microseconds and nanoseconds time part of this order.
 
std::int32_t getTimeNanoPart () const noexcept
 Returns microseconds and nanoseconds time part of this order.
 
std::int32_t getSequence () const noexcept
 Returns sequence number of this order to distinguish orders that have the same time.
 
void setSequence (std::int32_t sequence) noexcept
 Changes sequence number of this order.
 
std::int64_t getTimeNanos () const noexcept
 Returns time of this order in nanoseconds.
 
void setTimeNanos (std::int64_t timeNanos) noexcept
 Changes time of this order.
 
const OrderActiongetAction () const &noexcept
 Returns order action if available, otherwise - OrderAction::UNDEFINED.
 
void setAction (const OrderAction &action) noexcept
 Changes action of this order.
 
std::int64_t getActionTime () const noexcept
 Returns time of the last action.
 
void setActionTime (std::int64_t actionTime) noexcept
 Changes time of the last action.
 
std::int64_t getOrderId () const noexcept
 Returns order ID if available.
 
void setOrderId (std::int64_t orderId) noexcept
 Changes order ID.
 
std::int64_t getAuxOrderId () const noexcept
 Returns auxiliary order ID if available:
 
void setAuxOrderId (std::int64_t auxOrderId) noexcept
 Changes auxiliary order ID.
 
double getPrice () const noexcept
 Returns price of this order.
 
void setPrice (double price) noexcept
 Changes price of this order.
 
double getSize () const noexcept
 Returns size of this order.
 
void setSize (double size) noexcept
 Changes size of this order.
 
bool hasSize () const noexcept
 Returns true if this order has some size (sizeAsDouble is neither 0 nor NaN).
 
double getExecutedSize () const noexcept
 Returns executed size of this order.
 
void setExecutedSize (double executedSize) noexcept
 Changes executed size of this order.
 
std::int64_t getCount () const noexcept
 Returns number of individual orders in this aggregate order.
 
void setCount (std::int64_t count) noexcept
 Changes number of individual orders in this aggregate order.
 
std::int64_t getTradeId () const noexcept
 Returns trade (order execution) ID for events containing trade-related action.
 
void setTradeId (std::int64_t tradeId) noexcept
 Changes trade ID.
 
double getTradePrice () const noexcept
 Returns trade price for events containing trade-related action.
 
void setTradePrice (double tradePrice) noexcept
 Changes trade price.
 
double getTradeSize () const noexcept
 Returns trade size for events containing trade-related action.
 
void setTradeSize (double tradeSize) noexcept
 Changes trade size.
 
std::int16_t getExchangeCode () const noexcept
 Returns exchange code of this order.
 
std::string getExchangeCodeString () const noexcept
 Returns exchange code of this order as UTF8 string.
 
void setExchangeCode (char exchangeCode) noexcept
 Changes exchange code of this order.
 
void setExchangeCode (std::int16_t exchangeCode) noexcept
 Changes exchange code of this order.
 
const SidegetOrderSide () const &noexcept
 Returns side of this order.
 
void setOrderSide (const Side &side) noexcept
 Changes side of this order.
 
const ScopegetScope () const &noexcept
 Returns scope of this order.
 
void setScope (const Scope &scope) noexcept
 Changes scope of this order.
 
std::string baseFieldsToString () const noexcept
 Returns string representation of this order 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::EventType
virtual voidtoGraal () const noexcept=0
 Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
 
std::string toString () const noexcept override
 Returns a string representation of the current object.
 
- 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 Attributes

static constexpr std::uint32_t MAX_SEQUENCE = (1U << 22U) - 1U
 Maximum allowed sequence value.
 
- Static Public Attributes inherited from dxfcpp::IndexedEvent
static const EventFlag TX_PENDING = EventFlag::TX_PENDING
 0x01 - A bitmask to get transaction pending indicator from the value of eventFlags property.
 
static const EventFlag REMOVE_EVENT = EventFlag::REMOVE_EVENT
 0x02 - A bitmask to get removal indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_BEGIN = EventFlag::SNAPSHOT_BEGIN
 0x04 - A bitmask to get snapshot begin indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_END = EventFlag::SNAPSHOT_END
 0x08 - A bitmask to get snapshot end indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_SNIP = EventFlag::SNAPSHOT_SNIP
 0x10 - A bitmask to get snapshot snip indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_MODE = EventFlag::SNAPSHOT_MODE
 0x40 - A bitmask to set snapshot mode indicator into the value of eventFlags property.
 

Additional Inherited Members

- 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::IndexedEvent
using Ptr = std::shared_ptr<IndexedEvent>
 The alias to a type of shared pointer to the IndexedEvent object.
 
- Protected Member Functions inherited from dxfcpp::MarketEvent
 MarketEvent (std::string eventSymbol) noexcept
 Protected constructor for concrete implementation classes that initializes eventSymbol property.
 

Detailed Description

Base class for common fields of Order, AnalyticOrder and SpreadOrder events.

Order events represent a snapshot for a full available market depth for a symbol. The collection of order events of a symbol represents the most recent information that is available about orders on the market at any given moment of time.

Order event represents market depth for a specific symbol.

AnalyticOrder event represents market depth for a specific symbol extended with an analytic information, for example, whether particular order represent an iceberg or not.

SpreadOrder event represents market depth for all spreads on a given underlying symbol.

Order events arrive from multiple sources for the same market symbol and are distinguished by their index. Index is a unique per symbol identifier of the event. It is unique across all the sources of depth information for the symbol. The event with size either 0 or NaN is a signal to remove previously received order for the corresponding index. The method hasSize is a convenient method to test for size presence.

Event flags, transactions and snapshots

Some order event sources provide a consistent view of the price-level or detailed order book. Their updates may incorporate multiple changes to price levels or to individual orders that have to be processed at the same time. The corresponding information is carried in eventFlags property. The logic behind this property is detailed in IndexedEvent class documentation.

The event source identifier for an order is a part of the unique event index. It occupies highest bits of the index (index is not-negative). The lowest bits of index contain source-specific event index which is always zero in an event that is marked with EventFlag::SNAPSHOT_END bit in eventFlags.

Note that for an order with EventFlag::REMOVE_EVENT bit in eventFlags it is always the case that size is either 0 or NaN, so no additional logic to process this bit is required for orders. Transactions and snapshots may include orders with size of 0. The filtering that distinguishes those events as removals of orders shall be performed after all transactions and snapshot processing.

Some aggregated feeds (like CME market depth) are mapped into two distinct source ids (one for buy orders and one for sell orders), but updates and transactions may span both. It is important to keep a separate track of transactional state for each source id, but, at the same time, when DXFeedEventListener::eventsReceived() method is called for a list of events, the order book shall be considered complete and consistent only when all events from the given list are processed.

Constructor & Destructor Documentation

◆ OrderBase()

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

Creates new order event with the specified event symbol.

Parameters
eventSymbolThe event symbol.

Member Function Documentation

◆ baseFieldsToString()

std::string dxfcpp::OrderBase::baseFieldsToString ( ) const
noexcept

Returns string representation of this order event's fields.

Returns
string representation of this order event's fields.

◆ getAction()

const OrderAction & dxfcpp::OrderBase::getAction ( ) const &
inlinenoexcept

Returns order action if available, otherwise - OrderAction::UNDEFINED.

This field is a part of the FOB support.

Returns
order action or OrderAction::UNDEFINED.

◆ getActionTime()

std::int64_t dxfcpp::OrderBase::getActionTime ( ) const
inlinenoexcept

Returns time of the last action.

This field is a part of the FOB support.

Returns
time of the last order action.

◆ getAuxOrderId()

std::int64_t dxfcpp::OrderBase::getAuxOrderId ( ) const
inlinenoexcept

Returns auxiliary order ID if available:

This field is a part of the FOB support.

Returns
auxiliary order ID or 0 if not available.

◆ getCount()

std::int64_t dxfcpp::OrderBase::getCount ( ) const
inlinenoexcept

Returns number of individual orders in this aggregate order.

Returns
number of individual orders in this aggregate order.

◆ getEventFlags()

std::int32_t dxfcpp::OrderBase::getEventFlags ( ) const
inlineoverridevirtualnoexcept

Returns transactional event flags.

See EventFlag "Event Flags" section.

Returns
The transactional event flags.

Implements dxfcpp::IndexedEvent.

◆ getEventFlagsMask()

EventFlagsMask dxfcpp::OrderBase::getEventFlagsMask ( ) const
inlineoverridevirtualnoexcept

Returns transactional event flags.

See EventFlag "Event Flags" section.

Returns
The transactional event flags' mask.

Implements dxfcpp::IndexedEvent.

◆ getExchangeCode()

std::int16_t dxfcpp::OrderBase::getExchangeCode ( ) const
inlinenoexcept

Returns exchange code of this order.

Returns
exchange code of this order.

◆ getExchangeCodeString()

std::string dxfcpp::OrderBase::getExchangeCodeString ( ) const
inlinenoexcept

Returns exchange code of this order as UTF8 string.

Returns
exchange code of this order as UTF8 string.

◆ getExecutedSize()

double dxfcpp::OrderBase::getExecutedSize ( ) const
inlinenoexcept

Returns executed size of this order.

Returns
executed size of this order.

◆ getIndex()

std::int64_t dxfcpp::OrderBase::getIndex ( ) const
inlineoverridevirtualnoexcept

Returns unique per-symbol index of this order.

Index is non-negative.

Returns
unique per-symbol index of this order.

Implements dxfcpp::IndexedEvent.

◆ getOrderId()

std::int64_t dxfcpp::OrderBase::getOrderId ( ) const
inlinenoexcept

Returns order ID if available.

Some actions (OrderAction::TRADE, OrderAction::BUST) have no order ID since they are not related to any order in Order book.

This field is a part of the FOB support.

Returns
order ID or 0 if not available.

◆ getOrderSide()

const Side & dxfcpp::OrderBase::getOrderSide ( ) const &
inlinenoexcept

Returns side of this order.

Returns
side of this order.

◆ getPrice()

double dxfcpp::OrderBase::getPrice ( ) const
inlinenoexcept

Returns price of this order.

Returns
price of this order.

◆ getScope()

const Scope & dxfcpp::OrderBase::getScope ( ) const &
inlinenoexcept

Returns scope of this order.

Returns
scope of this order.

◆ getSequence()

std::int32_t dxfcpp::OrderBase::getSequence ( ) const
inlinenoexcept

Returns sequence number of this order to distinguish orders that have the same time.

This sequence number does not have to be unique and does not need to be sequential. Sequence can range from 0 to OrderBase::MAX_SEQUENCE.

Returns
sequence of this order.

◆ getSize()

double dxfcpp::OrderBase::getSize ( ) const
inlinenoexcept

Returns size of this order.

Returns
size of this order.

◆ getSource()

const OrderSource & dxfcpp::OrderBase::getSource ( ) const &
inlineoverridevirtualnoexcept

Returns source of this event.

The source is stored in the highest bits of the index of this event.

Returns
source of this event.

Implements dxfcpp::IndexedEvent.

◆ getTime()

std::int64_t dxfcpp::OrderBase::getTime ( ) const
inlinenoexcept

Returns time of this order.

Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC.

Returns
time of this order.

◆ getTimeNanoPart()

std::int32_t dxfcpp::OrderBase::getTimeNanoPart ( ) const
inlinenoexcept

Returns microseconds and nanoseconds time part of this order.

Returns
microseconds and nanoseconds time part of this order.

◆ getTimeNanos()

std::int64_t dxfcpp::OrderBase::getTimeNanos ( ) const
inlinenoexcept

Returns time of this order in nanoseconds.

Time is measured in nanoseconds between the current time and midnight, January 1, 1970 UTC.

Returns
time of this order in nanoseconds

◆ getTimeSequence()

std::int64_t dxfcpp::OrderBase::getTimeSequence ( ) const
inlinenoexcept

Returns time and sequence of this order packaged into single long value.

This method is intended for efficient order time priority comparison.

Returns
time and sequence of this order.

◆ getTradeId()

std::int64_t dxfcpp::OrderBase::getTradeId ( ) const
inlinenoexcept

Returns trade (order execution) ID for events containing trade-related action.

This field is a part of the FOB support.

Returns
trade ID or 0 if not available.

◆ getTradePrice()

double dxfcpp::OrderBase::getTradePrice ( ) const
inlinenoexcept

Returns trade price for events containing trade-related action.

This field is a part of the FOB support.

Returns
trade price of this action.

◆ getTradeSize()

double dxfcpp::OrderBase::getTradeSize ( ) const
inlinenoexcept

Returns trade size for events containing trade-related action.

This field is a part of the FOB support.

Returns
trade size.

◆ hasSize()

bool dxfcpp::OrderBase::hasSize ( ) const
inlinenoexcept

Returns true if this order has some size (sizeAsDouble is neither 0 nor NaN).

Returns
true if this order has some size (sizeAsDouble is neither 0 nor NaN).

◆ setAction()

void dxfcpp::OrderBase::setAction ( const OrderAction & action)
inlinenoexcept

Changes action of this order.

Parameters
actionThe action of this order.

◆ setActionTime()

void dxfcpp::OrderBase::setActionTime ( std::int64_t actionTime)
inlinenoexcept

Changes time of the last action.

Parameters
actionTimelast order action time.

◆ setAuxOrderId()

void dxfcpp::OrderBase::setAuxOrderId ( std::int64_t auxOrderId)
inlinenoexcept

Changes auxiliary order ID.

Parameters
auxOrderIdauxiliary order ID.

◆ setCount()

void dxfcpp::OrderBase::setCount ( std::int64_t count)
inlinenoexcept

Changes number of individual orders in this aggregate order.

Parameters
countnumber of individual orders in this aggregate order.

◆ setEventFlags() [1/2]

void dxfcpp::OrderBase::setEventFlags ( const EventFlagsMask & eventFlags)
inlineoverridevirtualnoexcept

Changes transactional event flags.

See EventFlag "Event Flags" section.

Parameters
eventFlagstransactional event flags' mask.

Implements dxfcpp::IndexedEvent.

◆ setEventFlags() [2/2]

void dxfcpp::OrderBase::setEventFlags ( std::int32_t eventFlags)
inlineoverridevirtualnoexcept

Changes transactional event flags.

See EventFlag "Event Flags" section.

Parameters
eventFlagstransactional event flags.

Implements dxfcpp::IndexedEvent.

◆ setExchangeCode() [1/2]

void dxfcpp::OrderBase::setExchangeCode ( char exchangeCode)
inlinenoexcept

Changes exchange code of this order.

Parameters
exchangeCodeexchange code of this order.

◆ setExchangeCode() [2/2]

void dxfcpp::OrderBase::setExchangeCode ( std::int16_t exchangeCode)
inlinenoexcept

Changes exchange code of this order.

Parameters
exchangeCodeexchange code of this order.

◆ setExecutedSize()

void dxfcpp::OrderBase::setExecutedSize ( double executedSize)
inlinenoexcept

Changes executed size of this order.

Parameters
executedSizeexecuted size of this order.

◆ setIndex()

void dxfcpp::OrderBase::setIndex ( std::int64_t index)
inlineoverridevirtualnoexcept

Changes unique per-symbol index of this order.

Note, that this method also changes source, whose id occupies highest bits of index. Use OrderBase::setSource() after invocation of this method to set the desired value of source.

Parameters
indexunique per-symbol index of this order.

Implements dxfcpp::IndexedEvent.

◆ setOrderId()

void dxfcpp::OrderBase::setOrderId ( std::int64_t orderId)
inlinenoexcept

Changes order ID.

Parameters
orderIdorder ID.

◆ setOrderSide()

void dxfcpp::OrderBase::setOrderSide ( const Side & side)
inlinenoexcept

Changes side of this order.

Parameters
sideside of this order.

◆ setPrice()

void dxfcpp::OrderBase::setPrice ( double price)
inlinenoexcept

Changes price of this order.

Parameters
priceprice of this order.

◆ setScope()

void dxfcpp::OrderBase::setScope ( const Scope & scope)
inlinenoexcept

Changes scope of this order.

Parameters
scopescope of this order.

◆ setSequence()

void dxfcpp::OrderBase::setSequence ( std::int32_t sequence)
inlinenoexcept

Changes sequence number of this order.

Parameters
sequencethe sequence.
See also
OrderBase::getSequence()

◆ setSize()

void dxfcpp::OrderBase::setSize ( double size)
inlinenoexcept

Changes size of this order.

Parameters
sizesize of this order.

◆ setSource()

void dxfcpp::OrderBase::setSource ( const OrderSource & source)
inlinenoexcept

Changes source of this event.

This method changes highest bits of the index of this event.

Parameters
sourcesource of this event.

◆ setTime()

void dxfcpp::OrderBase::setTime ( std::int64_t time)
inlinenoexcept

Changes time of this order.

Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC.

Parameters
timetime of this order.

◆ setTimeNanoPart()

void dxfcpp::OrderBase::setTimeNanoPart ( std::int32_t timeNanoPart)
inlinenoexcept

Changes microseconds and nanoseconds time part of this order.

Parameters
timeNanoPartmicroseconds and nanoseconds time part of this order.

◆ setTimeNanos()

void dxfcpp::OrderBase::setTimeNanos ( std::int64_t timeNanos)
inlinenoexcept

Changes time of this order.

Time is measured in nanoseconds between the current time and midnight, January 1, 1970 UTC.

Parameters
timeNanostime of this order in nanoseconds.

◆ setTimeSequence()

void dxfcpp::OrderBase::setTimeSequence ( std::int64_t timeSequence)
inlinenoexcept

Changes time and sequence of this order.

Warning
Do not use this method directly. Change time and/or sequence.
Parameters
timeSequencethe time and sequence.
See also
OrderBase::getTimeSequence()

◆ setTradeId()

void dxfcpp::OrderBase::setTradeId ( std::int64_t tradeId)
inlinenoexcept

Changes trade ID.

Parameters
tradeIdtrade ID.

◆ setTradePrice()

void dxfcpp::OrderBase::setTradePrice ( double tradePrice)
inlinenoexcept

Changes trade price.

Parameters
tradePricetrade price.

◆ setTradeSize()

void dxfcpp::OrderBase::setTradeSize ( double tradeSize)
inlinenoexcept

Changes trade size.

Parameters
tradeSizetrade size.

Member Data Documentation

◆ MAX_SEQUENCE

constexpr std::uint32_t dxfcpp::OrderBase::MAX_SEQUENCE = (1U << 22U) - 1U
staticconstexpr

Maximum allowed sequence value.

See also
OrderBase::setSequence()