EMA Consumer - Creating a barebones EMA consumer application

Download tutorial source code

Click here to download

Last update Aug 2024
Compilers Tutorial demonstration: Visual Studio 2022
Prerequisites Downloaded, installed, compiled, and ran an EMA consumer example



Introduction

The goal of this tutorial is to set up a Visual Studio project which defines the required compiler and linker options to successfully build and run. This tutorial will set up an application shell that enables us to perform basic EMA initialization.

Description

Market data is delivered to an application in an asynchronous event-driven manner. Applications use EMA API to subscribe to items. API delivers the initial data, subsequent updates, and status updates through callback events.

Steps

The goal of this tutorial is to set up a simple Visual Studio project, define a shell that performs basic EMA initialization, build and run the example successfully. The steps include:

  • Set up the Visual Studio Project
  • Implementation Overview - Shellcode for EMA initialization
  • Build and run

Set up the Visual Studio Project

All example projects can be installed in any location within your environment. Each project requires access to EMA API headers, library, configuration, and dictionary files.  To simplify the setup, each example project uses a single environment variable that is used when compiling and running. This will allow developers to easily copy/duplicate projects to other members without the need to modify project details, such as directory locations.

Define the project environment variables

  • RTSDK_CPP_HOME - Points to the home directory where the RTSDK C++ is installed.  Eg: C:\temp\RTSDK-2.2.0.L1..win.rrg

Once this step has been completed, all tutorials should compile without any configuration change.

Implementation Overview - Basic shellcode for EMA initialization

The basic shell utilizes a single source file Step1.cpp and its corresponding header file: Step1.h. For convenience, the shell contains an entry point and initialization routine that further tutorials will build on.

Class Definition: We include Ema.h, and define a custom class that extends from OmmConsumerClient. API will invoke onRefreshMsg, onUpdateMsg, and onStatusMsg of OmmConsumerClient, whenever there are any notifications (status update or market data) to be delivered.

Step1.h

    	
            

#include "Ema.h"

  

class AppClient : public refinitiv::ema::access::OmmConsumerClient   {

  

    void onRefreshMsg( ... );

    

    void onUpdateMsg( ... );

    

    void onStatusMsg( ... );

    

};

Implementation: An instance of AppClient is created in Step1.cpp. This instance will be passed in API calls to indicate that we intend to receive callbacks here:

    	
            

int main( int argc, char* argv[] )

{

  // create an instance of consumer client

  AppClient client;

  

  // block this thread for 1 minute

  sleep(60000);

  

  return 0;

}

You can see from above, this empty shell just includes a header file, and creates a type of EMA subclass, which is setup to receive events and updates from market data system. In the following tutorials, we will establish a connection and subscribe to market data.

Build and run

Assuming you have setup the environment variable, you can now compile and run the tutorial. If you encounter any compile errors, ensure your environment variable is properly defined. When you run the tutorial, you should see no errors and application will simply exit after a minute, at the command line.