CME iLink support

Preface

This article describes the FIX connectivity to iLink 2.X using the B2BITS FIX Antenna Java (tm) library CME iLink adaptor.

Overview

iLink 2.X is based on the FIX 4.2 protocol to establish and manage bi-directional sessions.

Using B2BITS FIX Antenna Java(tm) a user can establish connection with a FIX-over-FAST oriented

Quick start for CME iLink 2.X

This example provides a simple functionality for connecting to CME iLink server and reading data from it.

package com.epam.example;

import com.epam.common.FIXVersion;
import com.epam.fix.message.FIXField;
import com.epam.fix.message.FIXFieldList;
import com.epam.fix.message.FIXTypes;
import com.epam.fix.message.constants.FIXT11;
import com.epam.fixengine.FIXSession;
import com.epam.fixengine.FIXSessionListener;
import com.epam.fixengine.SessionParameters;
import com.epam.fixengine.SessionState;

import java.io.IOException;
import java.util.Calendar;

public class SimpleOrderSender {

    private static Object lockSync = new Object();

    public static void main(String[] args) throws IOException {

        // creating connection parameters
        SessionParameters details = new SessionParameters();
        details.setFixVersion(FIXVersion.FIX42);
        details.setHost("10.135.70.92");
        details.setHeartbeatInterval(30);
        details.setPort(10337);
        details.setSenderCompId("0D8004N");
        details.setTargetCompId("CME"); // always CME
        details.setSenderSubId("3B2");
        details.setTargetSubId("G");
        details.setSenderLocationId("USA");
        details.getIncomingLoginFixFieldList().add(new FIXField(95, "3"));
        details.getIncomingLoginFixFieldList().add(new FIXField(96, "3B2"));
        // During Logon process make sure that Sequence Number is set to 1 and tag 141 = Y
        // (these are requirements to establish the very first session during current working week)
        // All other mid-week logons should contain $141= N;
        // CME does not reset sequence numbers during whole week (except if reset was not initiated by Client)
        details.getIncomingLoginFixFieldList().add(new FIXField(141, "N"));

        // create session we intend to work with
        final FIXSession session = details.createNewFIXSession();

        // 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) {
                // this callback is called upon new message arrival

                String msgType = message.getTagStringValue(FIXT11.Header.MsgType);
                if("8".equals(msgType)) {
                    System.out.println("New execution report received: " + message);
                    // wait for any execution report
                    synchronized (lockSync) {
                        lockSync.notify();
                    }
                } else {
                    System.out.println("New message received: " + message);
                }
            }
        };

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

        // initiate connection
        try {
            session.connect();
        } catch (Exception e) {
            System.err.println("Error on connect. Cause: " + e.getMessage());
            System.exit(0);
        }

        // creates the order
        FIXFieldList order = createOrder();
        //send order
        sendNewOrder(session, order);

        // wait for execution reports
        waitForAnswer();
        // disconnecting
        session.disconnect("User request");
        // we don't want to received logout, shutdown immediately
        session.dispose();
    }

    private static void waitForAnswer() {
        synchronized (lockSync) {
            try {
                lockSync.wait(5000);
            } catch (InterruptedException e) {
            }
        }
    }

    private static void sendNewOrder(FIXSession session, FIXFieldList order) {
        System.out.println("Sending new order: " + order);
        session.sendMessage("D", order);
    }

    private static FIXFieldList createOrder() {
        final FIXFieldList order = new FIXFieldList();
        order.add(new FIXField(1, "ACCOUNT1"));
        order.add(new FIXField(21, "1"));
        order.add(new FIXField(11, "CLORDR:" + Long.toString(System.currentTimeMillis())));
        order.add(new FIXField(55, "963"));
        order.add(new FIXField(167, "FUT"));
        order.add(new FIXField(107, "1CLH1"));
        order.add(new FIXField(54, "1"));
        order.add(new FIXField(60, FIXTypes.formatUTCTimestamp(Calendar.getInstance())));
        order.add(new FIXField(38, "100"));
        order.add(new FIXField(40, "2"));
        order.add(new FIXField(44, "9825"));
        order.add(new FIXField(59, "0"));
        order.add(new FIXField(204, "0"));
        order.add(new FIXField(9702, "4"));
        order.add(new FIXField(9717, "90001210"));
        order.add(new FIXField(9768, "N"));
        return order;
    }
}

iLink MSGW

Key requirements:

How to create an application for iLink MSGW To create MSGW session you need special configuration for FIXAJ and special FIX dictionary. You can find example of configuration in "examples\etc\msgw\" and dictionary "ilink_dic\cmeilink_msgw_fix42.xml" in the cmeilinkadaptor package If you are not going to use a Fault Tolerance connection, you can use the example described above.

Example how to connect to iLink MSGW with Fault Tolerance you can find in cmeilinkadaptor package(examples\src\com\epam\example\msgw\SimpleOrderSenderSessionMSGW.java)

CME iLink adaptor configuration

iLink adaptor reads configurations parameters from the engine.properties file which is plased in appropriate etc directory of iLink distribution.

If this parameter is set to:


Generated on 10 Feb 2022 for FIXAntennaJava by  doxygen 1.6.1