Onix Solutions Logo

OnixS Java CME Straight Through Processing Handler — Programmer's Guide

Version 2.14.0

TOC

Introduction

Onix Solutions CME Straight Through Processing Handler allows clients to connect to CME for retrieval of FIXML 5.0 SP2 messages containing NYMEX, COMEX, DME, CBOT via CMD, CME cleared trades, CME Globex, BrokerTec Direct, and registered external deals information.

Handler provides the following services:

Note
We recommend reading the "CME STP API" alongside reading this Guide. By reading this Guide, we also recommend reviewing source code of the sample project which comes as a part of the library distributive package.

System Requirements

Getting Started

Using Handler usually includes the following:

Licensing the Handler

Specifying License Location

Handler needs a license for successful execution. If Handler is not able to find a valid license, it will throw an exception at the initialization stage.

biz.onixs.cme.stp.handler.Session class exposes a biz.onixs.cme.stp.handler.Session.#setLicenseDirectory member that allows instructing Handler where to look for a valid license. By default, Handler looks for a license in the current directory for the application that it uses, the home directory of the current user and a classpath. However, by using the noted parameter, it's possible to specify another folder anywhere on a file system.

Note
Handler looks for a valid license in the specified folder and selects the best one. If multiple licenses are available, it will select the most significant one.

Example

The following example demonstrates how we can supply license to Handler:


public class Sample {
    private void run() throws Exception {
        Session.setLicenseDirectory("d:\\licenses");

        final Session session = new Session(new URL(url), senderCompId, senderSubId, password);
    }
}

Working With Handler

Working with Handler

Main class to work with Handler is biz.onixs.cme.stp.handler.Session

To create the Session object there are four parameters (obtained from CME):

Example

The following example demonstrates how we can supply license to Handler:

final String url = "https://servicesnr.cmegroup.com/cmestp/query";
final String senderCompId = "SenderCompId";
final String senderSubId = "SenderSubId";
final String password = "Password";

final Session session = new Session(new URL(url), senderCompId, senderSubId, password);

Application Level

There are two ways to receive biz.onixs.cme.stp.handler.TradeCaptureReport messages:

Both ways can be used with or without filters. To specify filtering parameters biz.onixs.cme.stp.handler.TradeCaptureReportRequest message is used.

Note
Relationship between filters is "AND".

Example

The following example demonstrates how to request filter for all NYMEX products with "NG" or "NA" IDs, and negates NYMEX products with "CL" ID:

TradeCaptureReportRequest req = new TradeCaptureReportRequest();

RequestInstrument instrument1 = new RequestInstrument();
instrument1.setSecurityExchange("NYMEX");
req.getInstruments().add(instrument1);

RequestInstrument instrument2 = new RequestInstrument();
instrument2.setSecurityID("-CL");
req.getInstruments().add(instrument2);

RequestInstrument instrument3 = new RequestInstrument();
instrument3.setSecurityID("NG,NA");
req.getInstruments().add(instrument3);

Subscription

For real time data retrieval without filtering use biz.onixs.cme.stp.handler.Session.subscribe() or biz.onixs.cme.stp.handler.Session.subscribe(DateTime) methods.

For real time data retrieval with filtering use biz.onixs.cme.stp.handler.Session.subscribe(TradeCaptureReportRequest) method.

To continue reports retrieval Handler automatically sends requests for all active subscriptions every 3 seconds. This interval can be changed using biz.onixs.cme.stp.handler.Session constructor parameter.

Example

Session.setLicenseFile("../license/OnixS.Evaluator.Trial.lic");
Session session = new Session(new URL(url), senderCompId, senderSubId, password);
session.registerErrorListener(this);
session.registerMessageListener(this);
session.registerFixmlMessageListener(this);

String id = session.subscribe();

// Process received reports (if any) ...

session.unsubscribe(id);

Query

For historical data retrieval use the biz.onixs.cme.stp.handler.Session.query(TradeCaptureReportRequest) method.

Example

The following example demonstrates how to request filter for all NYMEX products with "NG" or "NA" IDs, and negates NYMEX products with "CL" ID:

Session.setLicenseFile("../license/OnixS.Evaluator.Trial.lic");
Session session = new Session(new URL(url), senderCompId, senderSubId, password);
session.registerErrorListener(this);
session.registerMessageListener(this);
session.registerFixmlMessageListener(this);

TradeCaptureReportRequest req = new TradeCaptureReportRequest();
req.setStartTime(DateTime.parse("2014-07-22"));
req.setEndTime(DateTime.parse("2014-07-28"));
RequestInstrument instrument = new RequestInstrument();
instrument.setSecurityID("EC");
instrument.setSecurityExchange("CME");
req.getInstruments().add(instrument);

session.query(req);

// Process received reports (if any) ...

Controlling Handler Logging

Controlling Logging in the Handler

By default, Handler logs all important aspects of its activity while processing market data. The SLF4J (Simple Logging Facade for Java) is used by Handler internally. The SLF4J detects and uses the concrete logging implementation configured by the user. By default, the Logback logging implementation is recommended.

The Logback (or any other logging implementation) must be configured at the beginning of the application. The examples of Logback configuration can be found in the Handler samples. The details of Logback configuration can be found here.

By default, logging is configured to log only errors and warnings. This is an example of logback.xml where detailed logging was switched on:
<logger name="biz.onixs.cme.stp.handler.sample" level="DEBUG"/>
<logger name="biz.onixs.cme.stp.handler" level="INFO"/>
<logger name="biz.onixs.cme.stp.handler.Session.Messages" level="INFO"/>

Resources


© Onix Solutions