MDP 3.0 support

Preface

This article describes the CME MDP 3.0 connectivity using the MDP 3.0 Java Adapter(tm) library.

Overview

With the Market Data Platform (MDP) 3.0 release, CME Group is implementing Simple Binary Encoding (SBE) to replace FAST compression. SBE is based on simple primitive encoding, which is optimized for low bandwidth, very low latency, and direct data access.

Using this adapter user can establish connection to CME MDP 3.0 and receive market data. API of CME MDP 3.0 Market Data Adapter is very similar to API of CME FAST Adapter and it very easy to migrate from previouse CME FAST implementation to new, which uses SBE encoding.

Quick start for CME

This example provides a simple functionality for connecting to CME server and reading data from it. The data is converted from the SBE format to the FIX format. The converted data is printed to console.

 {.java}
package com.epam.example;

import com.epam.common.transport.client.udp.UDPTransport;
import com.epam.cmemdp.full.session.client.*;
import com.epam.fix.FIXVersion;
import com.epam.fix.message.FIXFieldList;
import com.epam.fix.message.constants.FIXT11;
import com.epam.fixengine.*;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class CMEMDPClientSample {
    public static void main(String[] args) throws FileNotFoundException {

        final StreamClientFactory clientFactory = StreamClientFactory.createStreamFactory(new FileInputStream("templates.xml"));
        // create one chanel for connecting to the CME
        // snapshots
        final IStreamChannel snapshots = clientFactory.createStreamChannel(new UDPTransport("224.0.31.22", 14310), new FIXStreamListener() {
            public void onFIXMessage(FIXFieldList message) {
                System.out.println(message);
            }
        }, ChanelVersion.CME);
        // incremental updates
        final IStreamChannel incremental = clientFactory.createStreamChannel(new UDPTransport("224.0.31.1", 14310), new FIXStreamListener() {
            public void onFIXMessage(FIXFieldList message) {
                System.out.println(message);
            }
        }, ChanelVersion.CME);
        //Instrumental Replay
        final IStreamChannel replay = clientFactory.createStreamChannel(new UDPTransport("224.0.31.43", 14310), new FIXStreamListener() {
            public void onFIXMessage(FIXFieldList message) {
                System.out.println(message);
            }
        }, ChanelVersion.CME);
        // TCP Replay
        SessionParameters details = new SessionParameters();
        details.setFixVersion(FIXVersion.FIX42);
        details.setHost("205.209.222.43");
        details.setHeartbeatInterval(30);
        details.setPort(11000);
        details.setSenderCompId("senderId");
        details.setTargetCompId("targetId");

        // create a session we intend to work with
        final FIXSession session;
        try {
            session = details.createNewFIXSession();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        // listener for incoming messages and session state changes
        FIXSessionListener application = new FIXSessionListener() {
            // this method will be called every time session state is changed
            public void onSessionStateChange(SessionState sessionState) {
                System.out.println("Session state changed:" + sessionState);
                // this callback is called upon session state change
                if (sessionState == SessionState.DISCONNECTED) {
                    // end this session
                    session.dispose();
                }
            }

            // processing incoming messages
            public void onNewMessage(FIXFieldList message) {
                System.out.println("New application level message type: " + message.getTag(FIXT11.Header.MsgType).getStringValue() + " received ");
                // this callback is called upon a new message arrival
            }
        };

        // setting listener for incoming messages
        session.setFIXSessionListener(application);


        try {
            // connect to the channels
            snapshots.connect();
            incremental.connect();
            replay.connect();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Advance start for CME

This sections explains how to create a CME application step-by step with samples. The usual scenario to get it to work is:

CME MDP 3.0 Adaptor library allows application to subscribe to one or multiple instruments, supports all the features of CME market data channels including recovery. The CME distribution package includes the CMD tool application. This is console application which supports market recovery and subcribtion to instruments.

Createion of application parameters

The parameters is created in the following way:

// creates the application params
ApplicationParams params = new ApplicationParams();
// sets uri to config file
params.setUriToConfig(uriToConfig);
// sets uri to templates file
params.setUriToTemplates(uriToTemplates);
// sets network interface name
// params.setNetworkInterface("net1"); or params.setNetworkInterface("10.24.8.13");

Createion an application listener

The application listener is created in the following way:

// creates the application listener
ApplicationListener cmeAppListener = new ApplicationListener() {
public void process(FIXFieldList message) {
// process message code here
}

public void onError(String secDesc, long secID, String error) {
// process error code here
}
};

Createion an application instance

The application instance is created in the following way:

Application application = new ApplicationImpl(params, cmeAppListener);

Subscribe to instrument

// creates the instrument listener
InstrumentListener instrumentListener = new InstrumentListener(){
public void onSubscribed(String secDesc, long secID) {
}

public void onUnsubscribed(String secDesc, long secID) {
}

......... ..................

public void process(FIXFieldList fixMessage) {
}

public void onSnapshot(String secDesc, long secID, FIXFieldList msg) {
}

public void onBookReset(String secDesc, long secID) {
}

public void onError(String secDesc, long secID, String error) {
}
};
// subscribe by 'SYMBOL'
application.subscribeBySecurityDesc("SYMBOL", instrumentListener, RecoveryOptions.Market);

Close the application

The application can be closed in the following way:

application.unsubscribeAll();
application.stop();
Generated on Thu Sep 11 16:55:45 2014 for CMEMDP3.0MarketDataAdapter by  doxygen 1.6.3