Java TCP Handler for CME MDP 3.0 Conflated Feed
Introduction
This document introduces the Java TCP Handler, a component specifically engineered to interface with the conflated market data feed of the CME Market Data Platform (MDP 3.0). Designed to capitalize on the efficiency of this feed, the handler ensures low-latency delivery of market updates.
The CME Globex MDP 3.0 platform utilizes a conflated feed, meaning only the most recent market data updates for each instrument are transmitted. This approach significantly reduces bandwidth consumption and processing overhead, allowing for faster and more efficient data handling. The Java TCP Handler fully supports the features of this platform, effectively feeding real-time, conflated CME market data directly into your client application with microsecond-level latency.
About CME MDP 3.0 Conflated Feed
The CME MDP 3.0 platform offers a "conflated" TCP market data feed. Conflation, in this context, means that if multiple updates for the same market instrument occur within a short period, only the latest update is sent to the client application. This approach offers several key advantages:
Reduced Bandwidth Consumption: By transmitting only the most recent information, the conflated feed significantly reduces the amount of network bandwidth required. This is particularly beneficial for applications operating in environments with limited network capacity or when monitoring a large number of instruments.
Lower Processing Overhead: Client applications receiving a conflated feed experience lower processing loads. They only need to process the latest state of the market, rather than dealing with a high volume of intermediate updates that might be quickly superseded.
Focus on the Current Market State: For many trading and analytical applications, the most crucial piece of information is the current state of the market. The conflated feed ensures that applications always have the most up-to-date view without needing to process historical ticks within a short timeframe.
Improved Stability in High-Volume Periods: During periods of intense market activity, the number of raw market data updates can be extremely high. Conflation helps to smooth out these bursts of data, making the feed more manageable and stable for client applications.
Cost Efficiency: Lower bandwidth consumption can translate to reduced costs associated with network infrastructure and data processing, especially for high-frequency trading operations or large-scale data consumers.
In essence, the CME MDP 3.0 conflated TCP feed is optimized for efficiency. It prioritizes delivering the most current market information while minimizing the resources needed to transmit and process that data. This makes it an ideal choice for applications that require a near real-time understanding of the market without needing every single price tick.
Code Examples
package com.example;
import com.epmbfix.mdpconflatedtcp.impl.cme.CMEConnection;
import com.epmbfix.mdpconflatedtcp.impl.transport.TcpTransport;
import com.epmbfix.mdpconflatedtcp.interfaces.*;
import mdpsessionmgmt.RequestAck206Decoder;
import mdpsessionmgmt.SubscriptionReqType;
import mktdata.SnapshotFullRefresh38Decoder;
public class Main {
public static void main(String[] args) throws Exception {
Transport transport = new TcpTransport("127.0.0.1", 55506);
CMEConnection connection = CMEConnection
.builder()
.setFirm(Settings.FIRM)
.setAccessKeyId(Settings.ACCESS_ID)
.setSessionId(Settings.SESSION_ID)
.setSessionSignatureKey(Settings.KEY)
.setTransport(transport)
.build();
MDPSession mdpSession = connection.createSession();
mdpSession.addSessionListener(new SessionListener() {
@Override
public void onMessage(MDPIncomingMessage message, MDPSession session) {
if (message.getMessage() instanceof RequestAck206Decoder) {
// DO SOMETHING HERE
}
else if (message.getMessage() instanceof SnapshotFullRefresh38Decoder) {
SnapshotFullRefresh38Decoder snapshot = (SnapshotFullRefresh38Decoder) message.getMessage();
snapshot.lowLimitPrice().mantissa();
// DO SOMETHING HERE
}
}
@Override
public void onSessionStatusChanged(MDPSessionState state, MDPSession session) {
switch (state) {
case CREATED :
System.out.println("Session created");
break;
case ESTABLISHED:
System.out.println("Session established");
try {
session.securityListRequest(1, SubscriptionReqType.Snapshot, null, null);
session.securityStatusRequest(1, SubscriptionReqType.Snapshot, null, null);
session.marketDataRequest(1, SubscriptionReqType.Snapshot, null, null);
} catch (Exception e) {
e.printStackTrace();
}
break;
default :
// do something with default
break;
}
System.out.println("MDP Message status received");
}
});
mdpSession.connect().block();
System.out.println("GoodBye!");
}
}
How to build
This project utilizes Maven for building. To compile and package the application, execute the following command in your terminal:
mvn clean install
To generate the necessary Java encoder and decoder classes from the CME message templates, run the following Maven command:
mvn exec:exec
These generated classes are essential for the application to understand and process the market data messages from CME.
Sample application
This sample application provides a command-line interface to test the TCP client and its connection to the CME MDP server. You can start the application using the following command:
java -jar cme-mdp-conflated-tcp-1.0-jar-with-dependencies.jar <channel_id> <channel_settings_file>
Where:
<channel_id>
represents the identifier of the channel configuration you want to use. This ID corresponds to an entry in thechannel-settings.properties
file.<channel_settings_file>
is the path to the property file containing the connection settings required to establish a connection with CME.
The channel-settings.properties
file should be formatted as follows:
channels=51,517
channel.51.host=127.0.0.1
channel.51.port=55506
channel.51.sessionId=SESS2
channel.51.key=C_dE0vUUVpvR6r56Ee5fniujnpya9gE7cX-tOPsqZtM
channel.51.accessKeyId=<your security key>
channel.51.firm=FIRM1
channel.517.host=69.50.113.11
channel.517.port=9053
channel.517.sessionId=SESS2
channel.517.key=<your security key>
channel.517.accessKeyId=99Ygw5JTW2P2v2xWDOPN
channel.517.firm=FIRM2
After successfully starting the application, you will see the following menu:
1. Subscribe to security lists by SecurityGroup
2. Subscribe to security lists by SecurityID
3. Subscribe to security status by SecurityGroup
4. Subscribe to security status by SecurityID
5. Subscribe to MD by SecurityGroup
6. Subscribe to MD by SecurityID
MDP Message status received: TERMINATED
Session established
You can choose any of the listed options by entering the corresponding number. This will initiate the process of sending a subscription request to CME. Following your selection, another menu will appear asking for the subscription type:
Choose subscription type
1. Snapshot
2. SnapshotAndUpdates
3. Unsubscribe
For options involving SecurityGroup
, the application will prompt you to enter comma-separated security group values (e.g., FRTD,DFTR,FGDRT,...). Each group name is limited to a maximum of 6 characters. If any entered group name exceeds this limit, the subscription request will not be sent. You can specify up to 254 security groups in a single request. Entering nothing will send a subscription request for all available security groups.
For options involving SecurityID
, you will be asked to input comma-separated numeric security IDs (e.g., 74641523,74637936,74662010,74660473
). The same limitations apply as with security groups: a maximum of 254 IDs per request. Any non-numeric input will be ignored. Leaving the input empty will trigger a subscription request for all security groups and IDs.
Decoding solution
The process of parsing and decoding incoming market data messages relies on Java classes that are automatically generated from CME's message templates. These generated classes are included within the project and can be found in the mktdata
and mdpsessionmgmt
packages.
The DecoderImpl
class is responsible for implementing the decoding logic. During its initialization, this class scans the aforementioned packages to identify all classes related to decoding. It then utilizes these classes to interpret the raw market data received from CME.
TCP Connection
The underlying TCP connection to the server is managed by the AutoReconnectTcpClient
class. This class is designed to automatically attempt to re-establish the connection every 0.5 seconds if the connection is lost, ensuring a resilient and continuous data feed.
Messages samples
Here are some examples of the different types of messages you might encounter: