|
dxFeed Graal CXX API v9.0.0
|
Represents a model for market depth, tracking buy and sell orders and notifies listener of changes in the order book. More...
#include <MarketDepthModel.hpp>
Classes | |
| struct | Builder |
| A builder class for creating an instance of MarketDepthModel. More... | |
| struct | SortedOrderSet |
| Represents a set of orders, sorted by a comparator. More... | |
Public Member Functions | |
| std::size_t | getDepthLimit () const |
| void | setDepthLimit (std::size_t depthLimit) |
| Sets the depth limit of the model. | |
| std::int64_t | getAggregationPeriod () const |
| void | setAggregationPeriod (std::int64_t aggregationPeriodMillis) |
| Sets the aggregation period in milliseconds. | |
| void | setAggregationPeriod (std::chrono::milliseconds aggregationPeriod) |
| Sets the aggregation period. | |
| void | close () const |
| Closes this model and makes it permanently detached. | |
| Public Member Functions inherited from SharedEntity | |
| template<typename T> | |
| bool | is () const noexcept |
| Checks that the object is of type T: its dynamic type is T or derived from T. | |
| template<typename T> | |
| std::shared_ptr< T > | sharedAs () noexcept |
| Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nullptr} if the object is not managed by std::shared_ptr. | |
| 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 or std::shared_ptr<T>{nullptr} if the object is not managed by std::shared_ptr. | |
| virtual std::string | toString () const |
| Returns a string representation of the current object. | |
| Public Member Functions inherited from Entity | |
| virtual | ~Entity () noexcept |
| The default virtual d-tor. | |
Static Public Member Functions | |
| static std::shared_ptr< Builder > | newBuilder () |
| Creates a new builder instance for constructing a MarketDepthModel. | |
| Static Public Member Functions inherited from RequireMakeShared< MarketDepthModel< O > > | |
| static auto | createShared (Args &&...args) |
| Creates a smart pointer to an object. | |
Additional Inherited Members | |
| Public Types inherited from SharedEntity | |
| using | Ptr = std::shared_ptr<SharedEntity> |
| The alias to a type of shared pointer to the SharedEntity object. | |
Represents a model for market depth, tracking buy and sell orders and notifies listener of changes in the order book.
This model can set depth limit and aggregation period. This model notifies the user of received transactions through an installed MarketDepthModelListener.
The depth limit specifies the maximum number of buy or sell orders to maintain in the order book. For example, if the depth limit is set to 10, the model will only keep track of the top 10 buy orders and the top 10 sell orders. This helps in managing the size of the order book.
The aggregation period, specified in milliseconds, determines the frequency at which the model aggregates and notifies changes in the order book to the listeners. For instance, if the aggregation period is set to 1000 milliseconds the model will aggregate changes and notify listeners every second. A value of 0 means that changes are notified immediately.
This model must be configured using the Builder class, as most configuration settings cannot be changed once the model is built. This model requires configuration MarketDepthModel::Builder::withSymbol() and it must be MarketDepthModel::Builder::withFeed() attached to a DXFeed instance to begin operation.
This model only supports single symbol subscriptions; multiple symbols cannot be configured.
The convenient way to detach model from the feed is to call its MarketDepthModel::close() method. Closed model becomes permanently detached from all feeds, removes all its listeners.
This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
The model shows the orders that the endpoint has received, as they are: it does not correct them. A book can be crossed (the best buy order is above the best sell order) or show stale orders for reasons outside the API:
MarketDepthModel::Builder::withCrossedBookWarning() enables a check that reports a crossed book as a warning of the ErrorManager (see Error handling), so that such cases are seen in the log of the application. The check is disabled by default.
Sample:
| O | The type of order derived from OrderBase. |
|
inline |
Closes this model and makes it permanently detached.
A pending aggregated notification is cancelled, and the listener is not called after this method returns: it waits for the listener call in progress on another thread. The method can be called from the listener; called from a listener or a callback of the library, it does not wait (see ListenerCallScope).
References ListenerCallScope::isActive().
|
inline |
|
inline |
|
inlinestatic |
Creates a new builder instance for constructing a MarketDepthModel.
|
inline |
Sets the aggregation period.
| aggregationPeriod | The new aggregation period value. |
References setAggregationPeriod().
Referenced by setAggregationPeriod().
|
inline |
Sets the aggregation period in milliseconds.
| aggregationPeriodMillis | The new aggregation period value. |
|
inline |
Sets the depth limit of the model.
| depthLimit | The new depth limit value. |