This package grants you access to dxFeed market data. The library is designed as a С-library and directly invokes our flagship dxFeed Java API using Java Native Interface, making it easily integrable into your projects.
Our Java API serves as the cornerstone of our technology, and with our SDK, you can seamlessly integrate it into any language, leveraging it as a native library for all desktop platforms.
- 🚀 Performance almost is same as for our best Java API
- 🌌 Wider functionality
- ♊ Identical programming interfaces to our best API
- 👍 Higher quality of support and service
We use standalone JDK and specially written code that invokes Java methods from native using Java Native Iterface 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 (DxFeedJniNativeSdk.dylib|.so|.dll
) 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).
- Required components:
- preinstalled
Java VM 1.8+
JAR dependency
with:- latest Java API package Java API
- some Java wrappers for C ABI entry points
- C ABI implementation as
dynamic link library
(DxFeedJniNativeSdk.dylib|.so|.dll
)
- preinstalled
Code
#include <iostream>
#include <chrono>
#include <thread>
#include "api/dxfg_api.h"
void c_print(graal_isolatethread_t* thread, dxfg_event_type_list* events, void* user_data) {
for (int i = 0; i < events->size; ++i) {
dxfg_event_type_t* pEvent = events->elements[i];
if (pEvent && pEvent->clazz == DXFG_EVENT_QUOTE) {
const auto* quote = (const dxfg_quote_t*) pEvent;
printf(
"C: QUOTE{event_symbol=%s, bid_price=%f, bid_time=%lld, ask_price=%f, ask_time=%lld}\n",
quote->market_event.event_symbol,
quote->bid_price,
quote->bid_time,
quote->ask_price,
quote->ask_time);
}
}
}
int main() {
const auto address = "demo.dxfeed.com:7300";
const auto symbol = "AAPL";
auto thread = create_thread();
if (thread != nullptr) {
// Create endpoint and connect to specified address.
dxfg_endpoint_t* endpoint = dxfg_DXEndpoint_create(thread);
dxfg_DXEndpoint_connect(thread, endpoint, address);
// Create feed and subscription with specified types attached to feed.
dxfg_feed_t* feed = dxfg_DXEndpoint_getFeed(thread, endpoint);
dxfg_subscription_t* subscription = dxfg_DXFeed_createSubscription(thread, feed, DXFG_EVENT_QUOTE);
// Adds event listener.
dxfg_feed_event_listener_t* listener = dxfg_DXFeedEventListener_new(thread, &c_print, nullptr);
dxfg_DXFeedSubscription_addEventListener(thread, subscription, listener);
// Create STRING symbol.
dxfg_string_symbol_t stringSymbol;
stringSymbol.supper.type = STRING;
stringSymbol.symbol = symbol;
// Add symbol to subscription.
dxfg_DXFeedSubscription_setSymbol(thread, subscription, &stringSymbol.supper);
// Sleep 10 seconds waiting for the response about Quotes.
std::chrono::seconds seconds(10);
std::this_thread::sleep_for(seconds);
// Close subscription and clear resources.
dxfg_DXFeedSubscription_close(thread, subscription);
dxfg_DXEndpoint_close(thread, endpoint);
dxfg_JavaObjectHandler_release(thread, &listener->handler);
dxfg_JavaObjectHandler_release(thread, &subscription->handler);
dxfg_JavaObjectHandler_release(thread, &endpoint->handler);
}
- artifact
src/c/main/demo/build/dxfeed-jni-native-sdk-0.1.0.jar
$ git clone https://github.com/dxFeed/dxfeed-jni-native-sdk.git
$ cd dxfeed-jni-native-sdk
$ mvn clean package
- artifact
src/c/main/jni-lib/build/DxFeedJniNativeSdk.dylib|.so
$ cd src/main/c/jni-lib
$ sh build_release.sh
- artifact
src/c/main/jni-lib/build/DxFeedJniNativeSdk.dll
$ cd src\main\c\jni-lib
$ build_release.cmd
- artifact
src/c/main/demo/build/dxfeed-jni-native-sdk-0.1.0.jar
- artifact
src/c/main/demo/build/DxFeedJniNativeSdk.dylib|.so
- artifact
src/c/main/demo/build/DxFeedDemo
$ cd src/main/c
$ sh build_demo_release.sh
$ cd demo/build
$ ./DxFeedDemo demo.dxfeed.com:7300 AAPL
- artifact
src\c\main\demo\build\dxfeed-jni-native-sdk-0.1.0.jar
- artifact
src\c\main\demo\build\DxFeedJniNativeSdk.dll
- artifact
src\c\main\demo\build\DxFeedDemo.exe
$ cd src\main\c
$ build_demo_release.cmd
$ cd demo\build
$ DxFeedDemo.exe demo.dxfeed.com:7300 AAPL
Find useful information in our self-service dxFeed Knowledge Base:
- Demo is a sample demontration (linked with DxFeedJniNativeSdk) how to connect to address, add event listener and subscribe to
Quote
event - DxFeedConnect is a sample demontration how to connect to use console args to connect address and subscribe to
Quote
event - 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, using aDxFeed
instance singleton anddxfeed.properties
file - 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
- DxFeedPublishProfiles is a simple demonstration of how to publish market events
- ScheduleSample is a simple demonstration of how to get various scheduling information for instruments
- build JAR dependency ->
src/c/main/demo/build/dxfeed-jni-native-sdk-0.1.0.jar
- build native dependency ->
src/c/main/demo/build/DxFeedJniNativeSdk.dylib|.so|.dll
- copy to
${SAMPLE_DIR}/build
filesdxfeed-jni-native-sdk-0.1.0.jar
DxFeedJniNativeSdk.dylib|.so|.dll
cd ${SAMPLE_DIR}
- run script
sh build_release.sh
orbuild_release.cmd
- or open
CMakeLists.txt
as project and build from IDE
- or open
-
FEED connects to the remote data feed provider and is optimized for real-time or delayed data processing, this is a default role (.NET API sample)
-
STREAM_FEED is similar to
Feed
and also connects to the remote data feed provider but is designed for bulk data parsing from files (.NET API sample) -
PUBLISHER connects to the remote publisher hub (also known as multiplexor) or creates a publisher on the local host (.NET API sample)
-
STREAM_PUBLISHER is similar to
Publisher
and also connects to the remote publisher hub, but is designed for bulk data publishing (.NET API sample) -
LOCAL_HUB is a local hub without the ability to establish network connections. Events published via
Publisher
are delivered to localFeed
only -
ON_DEMAND_FEED is similar to
Feed
, but it is designed to be used with OnDemandService for historical data replay only
-
Order is a snapshot of the full available market depth for a symbol
-
SpreadOrder is a snapshot of the full available market depth for all spreads
-
AnalyticOrder is an
Order
extension that introduces analytic information, such as adding iceberg-related information to a given order -
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
-
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
-
Candle event with open, high, low, and close prices and other information for a specific period
-
Quote is a snapshot of the best bid and ask prices and other fields that change with each quote
-
Profile is a snapshot that contains the security instrument description
-
Summary is a snapshot of the trading session, including session highs, lows, etc.
-
TimeAndSale represents a trade or other market event with price, such as the open/close price of a market, etc.
-
Greeks is a snapshot of the option price, Black-Scholes volatility, and greeks
-
Series is a snapshot of computed values available for all options series for a given underlying symbol based on options market prices
-
TheoPrice is a snapshot of the theoretical option price computation that is periodically performed by dxPrice model-free computation
-
Underlying is a snapshot of computed values available for an option underlying symbol based on the market’s option prices
-
OptionSale represents a trade or another market event with the price (for example, market open/close price, etc.) for each option symbol listed under the specified
Underlying
-
Configuration is an event with an application-specific attachment
-
Message is an event with an application-specific attachment
-
String is a string representation of the symbol
-
TimeSeriesSubscriptionSymbol represents subscription to time-series events
-
IndexedEventSubscriptionSymbol represents subscription to a specific source of indexed events
-
WildcardSymbol.ALL represents a wildcard subscription to all events of the specific event type
-
CandleSymbol is a symbol used with DXFeedSubscription class to subscribe for Candle events
-
DXFeedSubscription is a subscription for a set of symbols and event types
-
DXFeedTimeSeriesSubscription extends
DXFeedSubscription
to conveniently subscribe to time series events for a set of symbols and event types (Java API sample) -
ObservableSubscription is an observable set of subscription symbols for the specific event type (Java API sample)
-
GetLastEvent returns the last event for the specified event instance (Java API sample)
-
GetLastEvents returns the last events for the specified event instances list
-
GetLastEventPromise requests the last event for the specified event type and symbol (Java API sample)
-
GetLastEventsPromises requests the last events for the specified event type and symbol collection
-
GetLastEventIfSubscribed returns the last event for the specified event type and symbol if there’s a subscription for it
-
GetIndexedEventsPromise requests an indexed events list for the specified event type, symbol, and source
-
GetIndexedEventsIfSubscribed returns a list of indexed events for the specified event type, symbol, and source, if there’s a subscription for it
-
GetTimeSeriesPromise requests time series events for the specified event type, symbol, and time range (Java API sample)
-
GetTimeSeriesIfSubscribed requests time series events for the specified event type, symbol, and time range if there’s a subscription for it
-
TimeSeriesEventModel is a model of a list of time series events (Java API sample)
-
IndexedEventModel is an indexed event list model (Java API sample)
-
OrderBookModel is a model of convenient Order Book management (Java API sample)
-
InstrumentProfile represents basic profile information about a market instrument (Java API sample)
-
InstrumentProfileReader reads instrument profiles from the stream using Instrument Profile Format (IPF)
-
InstrumentProfileCollector collects instrument profile updates and provides the live instrument profiles list (Java API sample)
-
InstrumentProfileConnection connects to an instrument profile URL and reads instrument profiles with support of streaming live updates
-
Schedule provides an API to retrieving and exploring the trading schedules of various exchanges and different financial instrument classes (Java API sample)
-
Option Series is a series of call and put options with different strike sharing the same attributes of expiration, last trading day, spc, multiplies, etc. (Java API sample)
- OnDemandService provides on-demand historical tick data replay controls (Java API sample)