This package provides access to dxFeed market data. The library is built as a language-specific wrapper over the dxFeed Graal Native library, which was compiled with GraalVM Native Image and dxFeed Java API (our flagman API).
ℹ️ If you already use dxFeed C API, please see
the Overview section.
- Overview
- Documentation
- Requirements
- Installation
- Usage
- Samples
- Current State
- Dependencies
- How To Build
- 3rd Party Licenses
The old version of dxFeed C API, has several architectural restrictions that prevent us from providing a state-of-the-art technological solution.
- 🚀 Increased performance
- 🌌 Wider functionality
- ♊ Identical programming interfaces to our best API
- 👍 Higher quality of support and service
Feature development has already stopped for the old version of dxFeed C API.
We expect the new repository to go into production in Q4’2023. At the same time, the old version will be considered deprecated, and at the end of 2024, we plan to end the service. If you’re already our customer and have difficulty with a future transition, please contact us via our customer portal.
Features planned with high priority:
- Add unit tests and conduct different types of testing
- Add necessary entities for more convenient API usage (IPF, TimeSeriesEventModel, OrderBookModel, GetTimeSeriesPromise, etc.)
- Provide more samples
- Provide performance test results along with a comparison with the old API version
Features planned for the next stage:
- Implement a model of incremental updates in Java API and add it to С/C++ API
- Implement OrderBookModel with advanced logic (e.g., OnNewBook, OnBookUpdate, OnBookIncrementalChange) in Java API and add it to C/C++ API
- Add samples or implement a convenient API for Candlewebservice
To help you rewrite the existing API calls, we’ve prepared samples demonstrating how to work with the new API and how several functionalities are implemented. More examples will follow. The table below shows the sample mapping between the old and new versions.
Our support team on our customer portal is ready to answer any questions and help with the transition.
# | Sample | Old Version | New Version |
---|---|---|---|
1 | How to subscribe to Quote , Trade , TradeETH , Order , SpreadOrder , AnalyticOrder , TimeAndSale events |
CommandLineSample | EventSample |
2 | How to subscribe to Candle event |
CandleSample | Q2’2023, please see TBD section |
3 | How to subscribe to Order , SpreadOrder , Candle , TimeAndSale , Greeks , Series snapshots |
SnapshotConsoleSample | Q2’2023, please see TBD section |
4 | How to subscribe to depth of market | PriceLevelBookSample | Q2’2023, please see TBD section |
5 | How to subscribe to order snapshot with incremental updates | IncSnapshotConsoleSample | Q2’2023, please see TBD section |
We use GraalVM Native Image technology and specially written code that wraps Java methods into native ones to get dynamically linked libraries for different platforms (Linux, macOS, and Windows) based on the latest Java API package.
Then, the resulting dynamic link library (dxFeed Graal-native) is used through C ABI (application binary interface), and we write programming interfaces that describe our business model (similar to Java API).
As a result, we get a full-featured, similar performance as with Java API. Regardless of the language, writing the final application logic using API calls will be very similar (only the syntax will be amended, "best practices", specific language restrictions)
Below is a scheme of this process:
# | Limitation | How It’s Solved in the New Version |
---|---|---|
1 | Single-threaded architecture limiting throughput. | Based on the Java API, each subscription object (DXFeedSubscription) can run on its own thread. |
2 | User code in event callbacks (for example, dxf_event_listener_t) is executed in the socket read thread, which can significantly reduce throughput. | Socket processing threads and callback threads are separated. |
3 | In event callbacks, one market event type and one data portion always arrive (excluding snapshot subscription), which increases the load on the CPU with a large amount of incoming data. | Event callbacks can receive different market event types, and more than one by batch. |
4 | It’s impossible to subscribe to data without getting regionals (if it is available for the market event) or only for a certain regional. | subscription->addSymbols({"AAPL"}); - compositesubscription->addSymbols({"AAPL&Q"}); - regional. |
5 | It’s impossible to subscribe to Order event (excluding snapshot subscription) without getting: all sources, Order by Quote (including regionals), Order by MarketMaker. | subscription->addSymbols(IndexedEventSubscriptionSymbol::create("AAPL", OrderSource::NTV)); - OrderSource determines which data is being subscribed to. |
6 | Data is mixed up when creating two subscriptions (regular and time series) for the same market event type. Both regular and time series data go to both subscriptions. | Each subscription instance receives only the data requested. |
7 | Each subsequent request for the same symbol set in a subscription instance overwrites the existing one in another subscription instance. | Subscription instances and the data they receive are independent of each other. |
8 | Removing a symbol from one subscription instance caused it to be removed from all others. | Subscription instances and the data they receive are independent of each other. |
9 | Incorrect behavior when reading from a file (if a market event in the file hasn’t been subscribed to). Reading from a file always occurs at maximum speed. The supported format is binary only. | endpoint->connect("file:tape.txt[format=text]"); - processing a text file with at it's "real" speed by timestampsendpoint->connect("file:tape.bin[format=binary,speed=max]"); - processing a binary file with max speed. |
Find useful information in our self-service dxFeed Knowledge Base or .NET API documentation:
Visual C++ Redistributable 2015
gcc 12.1+
Xcode 14.3+
Examples of how to install the library can be found here.
The API is delivered as a dynamic library (dxFeedGraalCxxApi.so|dll|dylib
) and a static one (dxFeedGraalCxxApi.a|lib
).
Also, it depends on DxFeedGraalNativeSdk.so|dll|dylib
. Please place it nearby or available on PATH
.
To use the dynamic library define the DXFCPP_USE_DLLS
preprocessor directive.
#include <iostream>
#include <dxfeed_graal_cpp_api/api.hpp>
int main() {
using namespace dxfcpp;
auto endpoint = DXEndpoint::newBuilder()
->withProperty("dxfeed.address", "demo.dxfeed.com:7300")
->build();
auto subscription = endpoint->getFeed()->createSubscription(Quote::TYPE);
subscription->addEventListener([](auto&& events) {
for (auto&& e : events) {
std::cout << e << "\n";
}
});
subscription->addSymbols({"AAPL"});
std::cin.get();
}
Output
I 221219 224811.681 [main] QD - Using QDS-3.313+file-UNKNOWN+mars-UNKNOWN+monitoring-UNKNOWN+tools-UNKNOWN, (C) Devexperts
I 221219 224811.695 [main] QD - Using scheme com.dxfeed.api.impl.DXFeedScheme DH2FdjP0DtOEIOAbE4pRVpmJsPnaZzAo1mICPJ6b06w
I 221219 224812.010 [main] QD - qd with collectors [Ticker, Stream, History]
I 221219 224812.017 [main] ClientSocket-Distributor - Starting ClientSocketConnector to demo.dxfeed.com:7300
I 221219 224812.017 [demo.dxfeed.com:7300-Reader] ClientSocketConnector - Resolving IPs for demo.dxfeed.com
I 221219 224812.021 [demo.dxfeed.com:7300-Reader] ClientSocketConnector - Connecting to 208.93.103.170:7300
I 221219 224812.170 [demo.dxfeed.com:7300-Reader] ClientSocketConnector - Connected to 208.93.103.170:7300
D 221219 224812.319 [demo.dxfeed.com:7300-Reader] QD - Distributor received protocol descriptor multiplexor@WQMPz [type=qtp, version=QDS-3.306, opt=hs, mars.root=mdd.demo-amazon.multiplexor-demo1] sending [TICKER, STREAM, HISTORY, DATA] from 208.93.103.170
Quote{AAPL, eventTime=0, time=20221219-223311.000, timeNanoPart=0, sequence=0, bidTime=20221219-223311, bidExchange=Q, bidPrice=132.16, bidSize=2, askTime=20221219-223311, askExchange=K, askPrice=132.17, askSize=10}
Quote{AAPL, eventTime=0, time=20221219-223312.000, timeNanoPart=0, sequence=0, bidTime=20221219-223312, bidExchange=Q, bidPrice=132.16, bidSize=6, askTime=20221219-223312, askExchange=K, askPrice=132.17, askSize=10}
Quote{AAPL, eventTime=0, time=20221219-223312.000, timeNanoPart=0, sequence=0, bidTime=20221219-223312, bidExchange=K, bidPrice=132.16, bidSize=10, askTime=20221219-223312, askExchange=V, askPrice=132.17, askSize=4}
- ConvertTapeFile demonstrates how to convert one tape file to another tape file with optional intermediate processing or filtering
- DxFeedFileParser is a simple demonstration of how events are read form a tape file
- DxFeedSample
is a simple demonstration of how to create multiple event listeners and subscribe to
Quote
andTrade
events - PrintQuoteEvents
is a simple demonstration of how to subscribe to the
Quote
event, using aDxFeed
instance singleton anddxfeed.properties
file - WriteTapeFile is a simple demonstration of how to write events to a tape file
- Order is a snapshot of the full available
market depth for a symbol
- dxFeed Graal C API
- dxFeed Graal C++ API
- SpreadOrder is a snapshot of the
full available market depth for all spreads
- dxFeed Graal C API
- dxFeed Graal C++ API
- AnalyticOrder represents an
extension of Order introducing analytic information, e.g., adding iceberg-related
information to this order
- dxFeed Graal C API
- dxFeed Graal C++ API
- Trade is a snapshot of the price and size
of the last trade during regular trading hours and an overall day
volume and day turnover
- dxFeed Graal C API
- dxFeed Graal C++ API
- TradeETH is a snapshot of the price
and size of the last trade during extended trading hours and the extended
trading hours day volume and day turnover
- dxFeed Graal C API
- dxFeed Graal C++ API
- Candle - event with open, high, low, and
close prices and other information for a specific period
- dxFeed Graal C API
- dxFeed Graal C++ API
- Quote is a snapshot of the best bid and
ask prices and other fields that change with each quote
- dxFeed Graal C API
- dxFeed Graal C++ API
- Profile is a snapshot that contains the
security instrument description
- dxFeed Graal C API
- dxFeed Graal C++ API
- Summary is a snapshot of the trading
session, including session highs, lows, etc.
- dxFeed Graal C API
- dxFeed Graal C++ API
- TimeAndSale - represents a trade or
other market event with price, like market open/close price, etc.
- dxFeed Graal C API
- dxFeed Graal C++ API
- Greeks is a snapshot of the option
price, Black-Scholes volatility, and Greeks
- dxFeed Graal C API
- dxFeed Graal C++ API
- Series is a snapshot of computed values
available for all options series for a given underlying symbol based on options market prices
- dxFeed Graal C API
- dxFeed Graal C++ API
- TheoPrice is a snapshot of the
theoretical option price computation that is periodically performed by dxPrice model-free computation
- dxFeed Graal C API
- dxFeed Graal C++ API
- Underlying is a snapshot of computed
values available for an option underlying symbol based on the market’s option prices
- dxFeed Graal C API
- dxFeed Graal C++ API
- Configuration is an event with an
application-specific attachment
- dxFeed Graal C API
- dxFeed Graal C++ API
- Message is an event with an
application-specific attachment
- dxFeed Graal C API
- dxFeed Graal C++ API
- String
- dxFeed Graal C API
- dxFeed Graal C++ API
- TimeSeriesSubscriptionSymbol -
represents subscription to time-series events
- dxFeed Graal C API
- dxFeed Graal C++ API
- IndexedSubscriptionSymbol -
represents subscription to a specific source of indexed events
- dxFeed Graal C API
- dxFeed Graal C++ API
- WildcardSymbol.ALL - represents a
wildcard subscription to all events of the specific event type
- dxFeed Graal C API
- dxFeed Graal C++ API
- CandleSymbol - symbol used
with DXFeedSubscription class to
subscribe for Candle events
- dxFeed Graal C API
- dxFeed Graal C++ API
- CreateSubscription creates a new
subscription for multiple event types attached to a specified feed
- dxFeed Graal C API
- dxFeed Graal C++ API
- CreateTimeSeriesSubscription
extends DXFeedSubscription to conveniently subscribe to time series of events for a set of symbols and event
types (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetLastEvent returns the last
event for the specified event
instance (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetLastEvents
returns the last events for the specified event instances list
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetLastEventPromise
requests the last event for the specified event type and
symbol (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetLastEventsPromises
requests the last events for the specified event type and symbol collection
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetLastEventIfSubscribed
returns the last event for the specified event type and symbol if there’s a subscription for it
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetIndexedEventsPromise
requests an indexed events list for the specified event type, symbol, and source
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetIndexedEventsIfSubscribed
requests an indexed events list for the specified event type, symbol, and source if there’s a subscription for it
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetTimeSeriesPromise
requests time series of events for the specified event type, symbol, and time
range (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- GetTimeSeriesIfSubscribed
requests time series of events for the specified event type, symbol, and time range if there’s a subscription for it
- dxFeed Graal C API
- dxFeed Graal C++ API
- TimeSeriesEventModel - is a model
of a list of time series
events (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- IndexedEventModel is a model of a
list of indexed
events (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- OrderBookModel is a model of
convenient Order Book
management (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- InstrumentProfile represents basic
profile information about a market
instrument (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- InstrumentProfileCollector
collects instrument profile updates and provides the live instrument profiles
list (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- Schedule provides API to retrieve and
explore various exchanges’ trading schedules and different financial instrument
classes (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- OnDemandService provides on-demand
historical tick data replay
controls (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- FEED connects to the remote data
feed provider and is optimized for real-time or delayed data processing (this is a default role)
- dxFeed Graal C API
- dxFeed Graal C++ API
- STREAM_FEED is similar to
FEED and also connects to the remote data feed provider but is designed for bulk data parsing from files
- dxFeed Graal C API
- dxFeed Graal C++ API
- LOCAL_HUB is a local hub
without the ability to establish network connections. Events published via publisher are delivered to local feed only.
- dxFeed Graal C API
- dxFeed Graal C++ API
- PUBLISHER connects to the
remote publisher hub (also known as multiplexor) or creates a publisher on the local
host (Java API sample)
- dxFeed Graal C API
- dxFeed Graal C++ API
- STREAM_PUBLISHER is
similar to PUBLISHER and also connects to the remote publisher hub, but is designed for bulk data publishing
- dxFeed Graal C API
- dxFeed Graal C++ API
- ON_DEMAND_FEED is similar
to FEED, but it is designed to be used with OnDemandService for historical data replay only
- dxFeed Graal C API
- dxFeed Graal C++ API