|
dxFeed Graal CXX API v9.0.0
|
This page explains how the events of the dxFeed model are delivered and what some fields mean, so that an expected behavior is not mistaken for a defect of the API. For connection problems see TROUBLESHOOTING.md.
| Events | Contract |
|---|---|
| Quote, Trade, TradeETH, Summary, Profile, OrderImbalance | ticker (conflated): the latest value per symbol |
| TimeAndSale | stream: the events are not conflated |
| TimeAndSale in a time-series subscription | history event |
| Order, AnalyticOrder, SpreadOrder, OtcMarketsOrder, ... | history (indexed events) |
For a ticker event only the latest value of a symbol is kept while a consumer is slow. The last value is delivered on a new subscription, but intermediate values are discarded as stale, so a Quote listener does not see every change of the market. This is the design, not a loss of data.
Practical consequence: to get every trade, subscribe to TimeAndSale, not to Trade. Trade is a snapshot of the last trade and its day volume; trades between two updates can be skipped. Stream events are not conflated, but a listener that is too slow can still lose them: DXFeedSubscription::getTotalDroppedEvents() counts such losses.
Orders are indexed events: they are also conflated per symbol and index, so an order book must be built from the events with their flags, see below.
Indexed events (orders, time series) carry flags, see EventFlag.hpp:
| Flag | Meaning |
|---|---|
| TX_PENDING | the event is a part of a transaction that is not complete yet |
| REMOVE_EVENT | remove the event with this index |
| SNAPSHOT_BEGIN | the loading of a snapshot starts (on a new subscription) |
| SNAPSHOT_END | the source has sent all the data for the subscription |
| SNAPSHOT_SNIP | a limit on the amount of data is reached: more data may exist but will not be provided |
Processing the flags by hand is error-prone: the state of every source is tracked separately, and a book is consistent only after the whole list of events of one call. Use a model that does it for you: IndexedTxModel, IndexedEventTxModel (one symbol and one source; delivers complete snapshots and transactions only), TimeSeriesTxModel and MarketDepthModel (an order book of the given depth).
A double field that has not been received is initialized as NaN in a fresh event (for example the bid and ask price and size of Quote, the price and size of a trade), so test such a value with std::isnan.
Do not read more into it than this: the documentation does not state that NaN means "no value" for every field. For orders there is an explicit rule: a size of 0 or NaN is a signal to remove a previously received order (OrderBase::hasSize() is false), see OrderBase.hpp.
Subscribing to Order with a plain symbol (without a source) means all the supported sources, not only OrderSource::DEFAULT. The synthetic and aggregate sources then come as separate _BID and _ASK sources (OrderSource::AGGREGATE_BID, OrderSource::AGGREGATE_ASK, and the like). The system property dxscheme.unitaryOrderSource=true selects the unitary sources (for example OrderSource::AGGREGATE) instead. Which of the sources send data for a symbol depends on the data provider.
To subscribe to one source, wrap the symbol into IndexedEventSubscriptionSymbol:
An order book of one source with the model:
Scope tells what an order of a book represents:
| Scope | Meaning |
|---|---|
| Scope::COMPOSITE | best bid and offer for the whole market |
| Scope::REGIONAL | best bid and offer for an exchange code |
| Scope::AGGREGATE | aggregate for a price level, or best bid and offer for a market maker |
| Scope::ORDER | an individual order |
The sources are described in OrderSource.hpp.
A book built from the data can be crossed (best bid above best ask) or locked (equal prices) for a short time. The reasons are listed in the class description of MarketDepthModel: lost or conflated data (a removal that never arrived), a slow client, and sources that deliver one side only or a book that combines several sources or exchanges, whose prices can legitimately cross for a moment. The model shows the orders as they are and does not correct them.
MarketDepthModel::Builder::withCrossedBookWarning(enabled, period) makes the model report a crossed book as a warning through ErrorManager. It is off by default, and the default period between two warnings is 1 minute:
The warning is reported only when the best bid price is strictly above the best ask price. A locked book is not reported, and a NaN price is not a crossing.
A wrong candle symbol is valid for the parser and for the feed: it gives no error, only no candles or other candles than expected. The page Candle symbols describes the format and the typical mistakes. CandleSymbol::valueOf() of a string and the _c literal report a warning for the likely ones, for example:
The wildcard symbol WildcardSymbol::ALL (*) works only if the endpoint is created with the system property dxfeed.wildcard.enable=true (DXEndpoint::DXFEED_WILDCARD_ENABLE_PROPERTY). It can create a very high network and CPU load and is meant for low-frequency events, see WildcardSymbol.hpp. Any other symbol that starts with * is ignored.