This package provides access to dxFeed market data.
Find useful information in self-service dxFeed Knowledge Base, or C API framework documentation:
- API
- Boost.Locale.EncodingUtf (1.75)
- TOML11 (3.6.0)
- Tests
- Catch2 (2.13.8)
- C++ Wrappers
- Args (6.2.2)
- fmt (8.0.0)
- optional-lite (3.1.1)
- string-view-lite (1.1.0)
- variant-lite (1.1.0)
System requirements (for the libressl): Visual C++ Redistributable 2015, Visual Studio.
Prerequisites: git
, cmake
, ninja
or make
, clang
(mingw or VS) or gcc
(mingw) or visual studio
git clone https://github.com/dxFeed/dxfeed-c-api.git
cd dxfeed-c-api
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_TLS=ON -DTARGET_PLATFORM=x64 ..
cmake --build . --config Release
Prerequisites: git
, cmake
, ninja
or make
, clang
or gcc
git clone https://github.com/dxFeed/dxfeed-c-api.git
cd dxfeed-c-api
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_TLS=ON -DTARGET_PLATFORM=x64 ..
cmake --build . --config Release
Prerequisites: git
, cmake
, ninja
or make
, clang
git clone https://github.com/dxFeed/dxfeed-c-api.git
cd dxfeed-c-api
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_TLS=ON -DTARGET_PLATFORM=x64 ..
cmake --build . --config Release
Prerequisites: git
, cmake
, ninja
, clang
git clone https://github.com/dxFeed/dxfeed-c-api.git
cd dxfeed-c-api
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_TLS=ON -DTARGET_PLATFORM=x64 ..
cmake --build . --config Release
# | EventType | Short description | Examples of original feed events | Struct |
---|---|---|---|---|
1 | Trade | The price and size of the last trade during regular trading hours, an overall day volume and day turnover | Trade (last sale), trade conditions change messages, volume setting events, index value | dxf_trade_t |
2 | TradeETH | The price and size of the last trade during extended trading hours, and the extended trading hours day volume and day turnover | Trade (last sale), trade conditions change messages, volume setting events | dxf_trade_t |
3 | TimeAndSale | The trade or other market event with price that provides information about trades in a continuous time slice (unlike Trade events, which are supposed to provide a snapshot of the current last trade) | Trade, index value | dxf_time_and_sale_t |
4 | Quote | The best bid and ask prices and other fields that may change with each quote. It represents the most recent information that is available about the best quote on the market | BBO Quote (bid/ask), regional Quote (bid/ask) | dxf_quote_t |
5 | Order | Depending on the scope flag it may be: composite BBO from the whole market or regional BBO from a particular exchange or aggregated information (e.g. PLB - price level book) or individual order (FOD - full order depth) |
Regional Quote (bid/ask), depth (order books, price levels, market maker quotes), market depth | dxf_order_t |
6 | SpreadOrder | Multi-leg order | Regional Quote (bid/ask), depth (order books, price levels, market maker quotes), market depth | dxf_order_t |
7 | Candle | OHLCV candle | Charting aggregations | dxf_candle_t |
8 | Profile | The most recent information that is available about the traded security on the market | Instrument definition, trading halt/resume messages | dxf_profile_t |
9 | Summary | The most recent OHLC information about the trading session on the market | OHLC setting events (trades, explicit hi/lo update messages, explicit summary messages) | dxf_summary_t |
10 | Greeks | Differential values that show how the price of an option depends on other market parameters | Greeks and Black-Scholes implied volatility | dxf_greeks_t |
11 | TheoPrice | The theoretical option price | Theoretical prices | dx_theo_price_t |
12 | Underlying | Calculated values that are available for an option underlying symbol based on the option prices on the market | VIX methodology implied volatility, P/C ratios | dxf_underlying_t |
13 | Series | Properties of the underlying | VIX methodology implied volatility, P/C ratios | dxf_series_t |
ℹ️ CODE SAMPLE: take a look at event_type usage in CommandLineSample |
---|
✅ READ MORE: Events to be published for different feed types, feed types and events matrix |
---|
There are three types of delivery contracts: Ticker
, Stream
and History
. You can set up the contract type by dx_event_subscr_flag as a parameter of dxf_create_subscription_with_flags.
The main task of this contract is to reliably deliver the latest value for an event (for example, for the last trade of the selected symbol). Queued older events could be conflated to conserve bandwidth and resources.
A stream contract guaranteedly delivers a stream of events without conflation.
History contract first delivers a snapshot (set of previous events) for the specified time range (subject to limitations). After the snapshot is transmitted, the history contract delivers a stream of events.
ℹ️ NOTE: if dx_event_subscr_flag is not set, the default contract type will be enabled. |
---|
Default contracts for events (in most cases):
Ticker | Stream | History |
---|---|---|
Trade | TimeAndSale | Order |
TradeETH | SpreadOrder | |
Quote | Candle | |
Profile | Series | |
Summary | Greeks | |
Greeks | ||
TheoPrice | ||
Underlying |
ℹ️ CODE SAMPLE: take a look at dx_event_subscr_flag usage in CommandLineSample |
---|
✅ READ MORE: Event delivery contracts |
---|
# | Method | Handle | Description | Code sample |
---|---|---|---|---|
1 | dxf_create_subscription dxf_create_subscription_with_flags |
dxf_subscription_t | Creates subscription to an event | CommandLineSample CommandLineSample |
2 | dxf_create_snapshot dxf_create_candle_snapshot dxf_create_order_snapshot |
dxf_snapshot_t | Creates a snapshot subscription | SnapshotConsoleSample SnapshotConsoleSample SnapshotConsoleSample |
3 | dxf_create_price_level_book | dxf_price_level_book_t | Creates the new price level book for the specified symbol and sources | PriceLevelBookSample |
4 | dxf_create_regional_book | dxf_regional_book_t | Creates a regional price level book | RegionalBookSample |
Order source in most cases identifies source of Order
and SpreadOrder
events. You can set Order source in subscription creation method (e.g. order_source_ptr
in dxf_create_order_snapshot()) or by dxf_set_order_source(). Several supported sources are listed below. Please find the full list here.
Aggregated:
-
AGGREGATE_ASK, AGGREGATE_BID - Ask, Bid side of an aggregate order book (futures depth and Nasdaq Level II)
Full order depth:
- BATE - Cboe EU BXE (BATE)
- BYX - Cboe BYX
- BZX - Cboe BZX
- BXTR - Cboe EU SI (Systematic Internaliser)
- BI20 - BIST Top20 Orders (Level2+)
- CHIX - Cboe EU CXE (Chi-X)
- CEUX - Cboe EU DXE
- CFE - Cboe CFE
- C2OX - Cboe C2
- DEA - Cboe EDGA
- DEX - Cboe EDGX
- ERIS - ErisX
- ESPD - Nasdaq E-speed
- FAIR - FairX
- GLBX - Globex
- ICE - ICE Futures US/EU
- IST - Borsa Istanbul
- MEMX - Members Exchange
- NTV - Nasdaq TotalView
- NFX - Nasdaq NFX
- SMFE - SmallEx
- XNFI - Nasdaq NFI
- XEUR - Eurex
Price level book:
- glbx - CME Globex
- iex - IEX
- memx - Members Exchange
- ntv - Nasdaq TotalView
- smfe - SmallEx
- xeur - Eurex
ℹ️ CODE SAMPLE: take a look at order_sources_ptr usage in PriceLevelBookSample |
---|
✅ READ MORE: Order sources |
---|
//connection handler declaration
dxf_connection_t connection;
//creating connection result declaration
ERRORCODE connection_result;
//creating connection
connection_result = dxf_create_connection(dxfeed_host, on_reader_thread_terminate, NULL, NULL, NULL, NULL, &connection);
//subscription handler declaration
dxf_subscription_t subscription;
//creating subscription result declaration
ERRORCODE subscription_result;
//creating subscription handler
subscription_result = dxf_create_subscription(connection, event_type, &subscription);
//creating subscription handler with Ticker contract
subscription_result = dxf_create_subscription_with_flags(connection, event_type, dx_esf_force_ticker, &subscription);
//adding array of symbols
dxf_add_symbols(subscription, (dxf_const_string_t*)symbols, symbol_count)
//setting Nasdaq TotalView FOD source
dxf_set_order_source(subscription, "NTV")
#include <stdio.h>
#include <time.h>
#include "DXFeed.h"
void print_timestamp(dxf_long_t timestamp) {
wchar_t timefmt[80];
struct tm* timeinfo;
time_t tmpint = (time_t)(timestamp / 1000);
timeinfo = localtime(&tmpint);
wcsftime(timefmt, 80, L"%Y%m%d-%H%M%S", timeinfo);
wprintf(L"%ls", timefmt);
}
void listener(int event_type, dxf_const_string_t symbol_name, const dxf_event_data_t* data, int data_count,
void* user_data) {
wprintf(L"%Quote{symbol=%ls, ", symbol_name);
dxf_quote_t* q = (dxf_quote_t*)data;
wprintf(L"bidTime=");
print_timestamp(q->bid_time);
wprintf(L" bidExchangeCode=%c, bidPrice=%f, bidSize=%i, ", q->bid_exchange_code, q->bid_price, q->bid_size);
wprintf(L"askTime=");
print_timestamp(q->ask_time);
wprintf(L" askExchangeCode=%c, askPrice=%f, askSize=%i, scope=%d}\n", q->ask_exchange_code, q->ask_price,
q->ask_size, (int)q->scope);
}
int main(int argc, char* argv[]) {
dxf_connection_t con;
dxf_subscription_t sub;
dxf_create_connection("demo.dxfeed.com:7300", NULL, NULL, NULL, NULL, NULL, &con);
dxf_create_subscription(con, DXF_ET_QUOTE, &sub);
dxf_const_string_t symbols2[] = {L"AAPL"};
dxf_attach_event_listener(sub, listener, NULL);
dxf_add_symbols(sub, symbols2, sizeof(symbols2) / sizeof(symbols2[0]));
wprintf(L"Press enter to stop\n");
getchar();
dxf_close_subscription(sub);
dxf_close_connection(con);
return 0;
}
Output:
Quote{symbol=AAPL, bidTime=20210826-174935 bidExchangeCode=A, bidPrice=148.020000, bidSize=0, askTime=20210826-174936 askExchangeCode=A, askPrice=148.050000, askSize=0, scope=1}
Quote{symbol=AAPL, bidTime=20210826-174901 bidExchangeCode=B, bidPrice=147.710000, bidSize=0, askTime=20210826-174916 askExchangeCode=B, askPrice=148.280000, askSize=0, scope=1}
Quote{symbol=AAPL, bidTime=20210826-174901 bidExchangeCode=C, bidPrice=147.740000, bidSize=0, askTime=20210826-174901 askExchangeCode=C, askPrice=148.210000, askSize=0, scope=1}
Quote{symbol=AAPL, bidTime=20170704-054404 bidExchangeCode=D, bidPrice=646.490000, bidSize=0, askTime=20170704-054404 askExchangeCode=D, askPrice=653.370000, askSize=0, scope=1}
Quote{symbol=AAPL, bidTime=20210826-174930 bidExchangeCode=H, bidPrice=147.560000, bidSize=0, askTime=20210826-174933 askExchangeCode=H, askPrice=148.200000, askSize=0, scope=1}
Quote{symbol=AAPL, bidTime=19700101-030000 bidExchangeCode=I, bidPrice=nan, bidSize=0, askTime=19700101-030000 askExchangeCode=I, askPrice=nan, askSize=0, scope=1}
Quote{symbol=AAPL, bidTime=20210826-174935 bidExchangeCode=J, bidPrice=147.890000, bidSize=0, askTime=20210826-174935 askExchangeCode=J, askPrice=148.220000, askSize=0, scope=1}
https://github.com/dxFeed/dxfeed-c-api/tree/master/samples:
- CandleSample - demonstrates how to subscribe to
Candle
event. - CommandLineSample - demonstrates how to subscribe to
Quote
,Trade
,TradeETH
,Order
,SpreadOrder
,Profile
,Summary
,TimeAndSale
,Underlying
,TheoPrice
,Series
,Greeks
,Configuration
events. - IncSnapshotConsoleSample - demonstrates how to subscribe to
Order
,SpreadOrder
,TimeAndSale
,Series
,Greeks
events with a snapshot and incremental updates. - PriceLevelBookSample - demonstrates how to subscribe to a price level book.
- RegionalBookSample - demonstrates how to subscribe to regional price level book.
- SnapshotConsoleSample - demonstrates how to subscribe to
Order
,SpreadOrder
,Candle
,TimeAndSale
,Greeks
,Series
snapshots. - FullOrderBookSample - demonstrates how to subscribe to full order book (FOB) with NTV order source.