This article describes the connectivity using the B2BITS CME High Level Market Data API.
The B2BITS CME High Level Market Data API is a library developed by B2BITS EPAM Systems Company (B2BITS) to provide with High-level access to CME Market Data.
B2BITS CME High Level Market Data API provides user application with built-in services:
This example provides a simple functionality for connecting to CME Market Data server and reading data from it. This example includes scenario based on pre-configuration of Subscriptions with binding of user applications listener to Subscription to handle Market Data. This example demonstrates Multiple Depth (Direct) Order Book provided via CME High Level Market Data API.
import com.epam.cmefast.marketdata.MarketDataApp; import com.epam.cmefast.marketdata.MarketDataAppFactory; import com.epam.cmefast.marketdata.cfg.ConfigHelper; import com.epam.cmefast.marketdata.cfg.Configuration; import com.epam.cmefast.marketdata.event.OrderBookListener; import com.epam.cmefast.marketdata.example.util.CmeMarketDataUtil; import com.epam.cmefast.marketdata.model.BookPriceData; import com.epam.cmefast.marketdata.model.OrderBook; import com.epam.cmefast.marketdata.model.OrderBookState; import com.epam.fix.message.FIXFieldList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DirectBookExample { private static final Logger logger = LoggerFactory.getLogger(DirectBookExample.class); public static void main(String[] args) { try { new DirectBookExample().handleMarketData(); } catch (Exception e) { logger.error("Error in example", e); } } public void handleMarketData() throws Exception { logger.info("DirectBookExample has been started ..."); // create instance of MarketDataApp final MarketDataApp mdApp = MarketDataAppFactory.createMarketDataApp(); // load configuration of Subscriptions (if you work via pre-configurated Subscriptions) Configuration mdAppCfg = ConfigHelper.loadConfiguration(getClass().getClassLoader().getResource("jfast-cme-md-func-directbook.cfg")); // bind listeners to required Subscriptions from configuration mdAppCfg.bindDirectBookListener("SSCRPTN001", new OrderBookListener() { public void onBookStateChanged(OrderBook book, OrderBookState oldState, OrderBookState newState) { logger.info("Direct onBookStateChanged: type: [{}], security: [{}], prevState: [{}], newState: [{}]", book.getBookType(), book.getSecurityDef().getSecurityDesc(), oldState, newState); } public void onOrderBookUpdated(OrderBook book, FIXFieldList source) { logger.info("Direct onOrderBookUpdated: security: [{}]", book.getSecurityDef().getSecurityDesc()); CmeMarketDataUtil.printDirectOrderBook(book); } public void onOrderBookTopOfTheBookUpdated(Long securityId, BookPriceData topBid, BookPriceData topAsk, FIXFieldList source) { logger.info("New top of the Direct Book of security [{}]: [{}]|[{}]|[{}]|[{}]", securityId, topBid.getQuantity(), topBid.getPrice(), topAsk.getPrice(), topAsk.getQuantity()); } }); // start to connect and handle CME Market Data mdApp.init(mdAppCfg); mdApp.start(); Thread.sleep(300000); // shutdown stream and disconnect mdApp.stop(); } }
The following table lists all Subscription Options and appropriate Listenters to bind to listen Market Data events.
Subscription Option | Purpose | Listener to bind to get events | Example Names |
DIRECT | Multiple Depth Book | Multiple Depth Book com.epam.cmefast.marketdata.event.OrderBookListener | DirectBookExample, DirectAndImpliedBookExample, AdhocBookExample |
IMPLIED | Implied Book | com.epam.cmefast.marketdata.event.ImpliedOrderBookListener | ImpliedBookExample, DirectAndImpliedBookExample |
CONSOLIDATED | Consolidated Book | com.epam.cmefast.marketdata.event.ConsolidatedOrderBookListener | ConsolidatedBookExample, AdhocBookExample |
TRADE | Last Trades | com.epam.cmefast.marketdata.event.TradeListener | LastTradeBySecDescExample, LastTradeBySecurityGroupExample |
QUOTEREQUEST | Quote Requests | com.epam.cmefast.marketdata.event.QuoteRequestListener | |
STATISTICS | Statistics | com.epam.cmefast.marketdata.event.StatisticsListener | StatisticsBySecuritySymbolExample |
STATUS | Security Status | com.epam.cmefast.marketdata.event.SecurityStatusListener | |
SECURITY | All security related events (excepting Book) | com.epam.cmefast.marketdata.event.SecurityEventsListener |