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

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

#include <OrderBase.hpp>

+ Inheritance diagram for 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) 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)
 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)
 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 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 EventType
virtual void * toGraal () const =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 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 Attributes

static constexpr std::uint32_t MAX_SEQUENCE = (1U << 22U) - 1U
 Maximum allowed sequence value.
 
- Static Public Attributes inherited from 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 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 IndexedEvent
using Ptr = std::shared_ptr<IndexedEvent>
 The alias to a type of shared pointer to the IndexedEvent object.
 
- Protected Member Functions inherited from 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()

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 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 & 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 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 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 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 OrderBase::getEventFlags ( ) const
inlineoverridevirtualnoexcept

Returns transactional event flags.

See EventFlag "Event Flags" section.

Returns
The transactional event flags.

Implements IndexedEvent.

◆ getEventFlagsMask()

EventFlagsMask OrderBase::getEventFlagsMask ( ) const
inlineoverridevirtualnoexcept

Returns transactional event flags.

See EventFlag "Event Flags" section.

Returns
The transactional event flags' mask.

Implements IndexedEvent.

◆ getExchangeCode()

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

Returns exchange code of this order.

Returns
exchange code of this order.

◆ getExchangeCodeString()

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

Returns exchange code of this order as UTF8 string.

Returns
exchange code of this order as UTF8 string.

◆ getExecutedSize()

double OrderBase::getExecutedSize ( ) const
inlinenoexcept

Returns executed size of this order.

Returns
executed size of this order.

◆ getIndex()

std::int64_t 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 IndexedEvent.

◆ getOrderId()

std::int64_t 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 & OrderBase::getOrderSide ( ) const &
inlinenoexcept

Returns side of this order.

Returns
side of this order.

◆ getPrice()

double OrderBase::getPrice ( ) const
inlinenoexcept

Returns price of this order.

Returns
price of this order.

◆ getScope()

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

Returns scope of this order.

Returns
scope of this order.

◆ getSequence()

std::int32_t 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.

References MAX_SEQUENCE.

Referenced by setTime().

◆ getSize()

double OrderBase::getSize ( ) const
inlinenoexcept

Returns size of this order.

Returns
size of this order.

◆ getSource()

const OrderSource & 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 IndexedEvent.

◆ getTime()

std::int64_t 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.

Referenced by getTimeNanos().

◆ getTimeNanoPart()

std::int32_t 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 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

References getTime().

◆ getTimeSequence()

std::int64_t 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 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 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 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 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 OrderBase::setAction ( const OrderAction & action)
inlinenoexcept

Changes action of this order.

Parameters
actionThe action of this order.

Referenced by Order::withAction(), and SpreadOrder::withAction().

◆ setActionTime()

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

Changes time of the last action.

Parameters
actionTimelast order action time.

Referenced by Order::withActionTime(), and SpreadOrder::withActionTime().

◆ setAuxOrderId()

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

Changes auxiliary order ID.

Parameters
auxOrderIdauxiliary order ID.

Referenced by Order::withAuxOrderId(), and SpreadOrder::withAuxOrderId().

◆ setCount()

void 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.

Referenced by Order::withCount(), and SpreadOrder::withCount().

◆ setEventFlags() [1/2]

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

Changes transactional event flags.

See EventFlag "Event Flags" section.

Parameters
eventFlagstransactional event flags' mask.

Implements IndexedEvent.

References EventFlagsMask::getMask().

◆ setEventFlags() [2/2]

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

Changes transactional event flags.

See EventFlag "Event Flags" section.

Parameters
eventFlagstransactional event flags.

Implements IndexedEvent.

◆ setExchangeCode() [1/2]

void OrderBase::setExchangeCode ( char exchangeCode)
inline

Changes exchange code of this order.

Parameters
exchangeCodeexchange code of this order.

Referenced by setExchangeCode().

◆ setExchangeCode() [2/2]

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

Changes exchange code of this order.

Parameters
exchangeCodeexchange code of this order.

References setExchangeCode().

◆ setExecutedSize()

void OrderBase::setExecutedSize ( double executedSize)
inlinenoexcept

Changes executed size of this order.

Parameters
executedSizeexecuted size of this order.

Referenced by Order::withExecutedSize(), and SpreadOrder::withExecutedSize().

◆ setIndex()

void OrderBase::setIndex ( std::int64_t index)
inlineoverridevirtual

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 IndexedEvent.

Referenced by Order::withIndex(), and SpreadOrder::withIndex().

◆ setOrderId()

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

Changes order ID.

Parameters
orderIdorder ID.

Referenced by Order::withOrderId(), and SpreadOrder::withOrderId().

◆ setOrderSide()

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

Changes side of this order.

Parameters
sideside of this order.

Referenced by Order::withOrderSide(), and SpreadOrder::withOrderSide().

◆ setPrice()

void OrderBase::setPrice ( double price)
inlinenoexcept

Changes price of this order.

Parameters
priceprice of this order.

Referenced by Order::withPrice(), and SpreadOrder::withPrice().

◆ setScope()

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

Changes scope of this order.

Parameters
scopescope of this order.

Referenced by Order::withScope(), and SpreadOrder::withScope().

◆ setSequence()

void OrderBase::setSequence ( std::int32_t sequence)
inline

Changes sequence number of this order.

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

References MAX_SEQUENCE.

Referenced by Order::withSequence(), and SpreadOrder::withSequence().

◆ setSize()

void OrderBase::setSize ( double size)
inlinenoexcept

Changes size of this order.

Parameters
sizesize of this order.

Referenced by Order::withSize(), and SpreadOrder::withSize().

◆ setSource()

void 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.

References IndexedEventSource::id(), and OrderSource::isSpecialSourceId().

Referenced by Order::withSource(), and SpreadOrder::withSource().

◆ setTime()

void 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.

References getSequence().

Referenced by setTimeNanos(), Order::withTime(), and SpreadOrder::withTime().

◆ setTimeNanoPart()

void 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.

Referenced by Order::withTimeNanoPart(), and SpreadOrder::withTimeNanoPart().

◆ setTimeNanos()

void 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.

References setTime().

Referenced by Order::withTimeNanos(), and SpreadOrder::withTimeNanos().

◆ setTimeSequence()

void 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 OrderBase::setTradeId ( std::int64_t tradeId)
inlinenoexcept

Changes trade ID.

Parameters
tradeIdtrade ID.

Referenced by Order::withTradeId(), and SpreadOrder::withTradeId().

◆ setTradePrice()

void OrderBase::setTradePrice ( double tradePrice)
inlinenoexcept

Changes trade price.

Parameters
tradePricetrade price.

Referenced by Order::withTradePrice(), and SpreadOrder::withTradePrice().

◆ setTradeSize()

void OrderBase::setTradeSize ( double tradeSize)
inlinenoexcept

Changes trade size.

Parameters
tradeSizetrade size.

Referenced by Order::withTradeSize(), and SpreadOrder::withTradeSize().

Member Data Documentation

◆ MAX_SEQUENCE

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

Maximum allowed sequence value.

See also
OrderBase::setSequence()

Referenced by getSequence(), and setSequence().