Article

How to get Exchange Information from a Market Price Domain using EMA Java

Wasin Waeosri
Developer Advocate Developer Advocate

How to get Exchange Information from a Market Price Domain

Overview

Update: December 2020

For some instruments, the suffix of RIC indicates the exchange where it is traded, e.g. HSBA.L (.L = LSE - London Stock Exchange), HBC.N (.N = NYSE - New York Stock Exchange). However, there are some instruments without the exchange code suffix like TWXF2Z7 (Time Warner DEC7), KC4F5Z7 (Kone Corp DEC7), etc. How does the application know the exchange of those instruments?

Solution

Refinitiv Real-Time provides a short exchange name information via the FID 1709 (Field name RDN_EXCHD2) for the Market Price domain. This FID 1709 is the enumeration field that is used in most of the exchanges. The Refinitiv Real-Time SDK 1.1.0 (Enterprise Message API Java 3.1.0) (formerly known as Elektron SDK/Elektron Message API) and above can retrieve an enum value from dictionary directly, so it can help a consumer application get a short exchange name from this enumeration field.

IMPORTANT Rebranding Announcement:

Starting with version RTSDK 2.0.0.L1 (same as EMA/ETA 3.6.0.L1), there are namespace changes and library name changes. Please note that all interfaces remain the same as prior releases of RTSDK and Elektron SDK and will remain fully wire compatible. Along with RTSDK 2.X version, a REBRAND.md is published to detail impact to existing applications and how to quickly adapt to the re-branded libraries. Existing applications will continue to work indefinitely as-is. Applications should be proactively rebranded to be able to utilize new features, security updates or fixes post 2.X release. Please see PCN for more details on support.

RDMFieldDictionary

    	
            
RDN_EXCHD2 "EXCHANGE ID 2"       1709  NULL        ENUMERATED    5 ( 3 )  ENUM             2

enumtype.def

    	
            

RDN_EXCHD2  1709

...

! VALUE      DISPLAY   MEANING

! -----      -------   -------

      0        "   "   undefined

      1        "ASE"   NYSE AMEX

      2        "NYS"   New York Stock Exchange

      3        "BOS"   Boston Stock Exchange

      4        "CIN"   National Stock Exchange (formerly Cincinnati Stock Exchange)

      5        "PSE"   NYSE Arca

      6        "XPH"   NASDAQ OMX PSX when trading in SIAC (formerly Philadelphia Stock Exchange)

    ...

      1454     "PCW"   PetroChem Wire LLC

      1455     "SMP"   Euronext - Smartpool

      1456     "BT1"   BATS ONE - LEVEL 1 (PRODUCT)

Solution Code

This 1709 FID is an enumeration field type consisting of a set of mnemonics; each with its specific meaning. A displayable string represents each exchange short name is associated with each of these mnemonics. The mapping between mnemonics and the displayable string is required to get a suitable and meaningful exchange short name. The EMA Java 3.1.0 API (and above) can help the application gets an enumeration field value and map it to a displayable value with only a few line of code.

Please see the ExchangeName example that modified from EMA Java's ex360_MP_View (example360__MarketPrice__View in previous versions) example to subscribe and handle FID 1709 below.

1.    Firstly, we create the OMM ElementList object to keep the OMM Payload and the OMM Array to keep interested FIDs in the ExchangeName class

    	
            

public class ExchangeName{

      ...

      //View

      ElementList view = EmaFactory.createElementList();

      OmmArray view_array = EmaFactory.createOmmArray();

}

2.    Then we add the interested FIDs including 1709 to the OMM Array

    	
            

public class ExchangeName{

      ...

      //View

      ElementList view = EmaFactory.createElementList();

      OmmArray view_array = EmaFactory.createOmmArray();

 

 

    view_array.fixedWidth(2);

      view_array.add(EmaFactory.createOmmArrayEntry().intValue(3)); //DSPLY_NAME

    view_array.add(EmaFactory.createOmmArrayEntry().intValue(22)); //BID

    view_array.add(EmaFactory.createOmmArrayEntry().intValue(25)); //ASK

      view_array.add(EmaFactory.createOmmArrayEntry().intValue(1709)); //RDN_EXCHD2

}

3.    Next, we add the OMM Array to the view ElementList by setting VIEW Type to 1 (FID) and VIEW Data to the array

    	
            

public class ExchangeName{

      ...

      //View

      ...

      view.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));

      view.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, view_array));

}

4.    Next, we create the ReqMsg object and set the view ElementList as a request's payload. EMA Java will send a snapshot item request (non-streaming) to Refinitiv Real-Time Advanced Distribution Server with the View feature.

    	
            

public class ExchangeName{

      ...

      //View

      ...

      view.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));

      view.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, view_array));

 

      consumer.registerClient(EmaFactory.createReqMsg()

                            .serviceName("ELEKTRON_DD")

                            .name("TRI.N")

                            .interestAfterRefresh(false)

                            .payload(view)

                    , appClient);

}

5.    In the OmmConsumerClient application code, we implement the decode function that iterates incoming data FieldList in the onRefreshMsg and onUpdateMsg callbacks

    	
            

class AppClient implements OmmConsumerClient

      public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event){

            ...

            if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType())

                  decode(refreshMsg.payload().fieldList());

      }

}

6.    We implement the decode function to handle and print out DataTypes.ENUM, so the application will get FID 1709 enumerate value (enumtype.def) automatically.

    	
            

class AppClient implements OmmConsumerClient

      public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event){

            ...

            if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType())

                  decode(refreshMsg.payload().fieldList());

      }

      ...

      void decode(FieldList fieldList){

            for (FieldEntry fieldEntry : fieldList){

            System.out.print("Fid: " + fieldEntry.fieldId() + " Name = " + fieldEntry.name() + " DataType: " + DataType.asString(fieldEntry.load().dataType()) + " Value: ");

 

            if (Data.DataCode.BLANK == fieldEntry.code())

                System.out.println(" blank");

            else

                switch (fieldEntry.loadType()){

                              ...

                              case DataTypes.ENUM: //Handle FID 1709

                                    System.out.println(fieldEntry.hasEnumDisplay() ? fieldEntry.enumDisplay() : fieldEntry.enumValue());

                                    break;

                              case DataTypes.RMTES: //Handle FID 3

                                    System.out.println(fieldEntry.rmtes());

                                    break;

                              ...

                        }

      }

}

Running the application

The application source code is available at GitHub. You can get it via the following git command

    	
            
$>git clone git@github.com:Refinitiv-API-Samples/Article.EMA.Java.ExchangeShortName.git

Note: The application works with EMA Java 3.6.0 (Real-Time SDK 2.0.0) and above which supports the enum parsing only.

You can build the application and run it via the following steps

  1. Install and configure Apache ANT and Apache IVY in your machine
  2. Configure the Channel_1 of EmaConfig.xml file to specify the host name and RSSL Port of the server (Refinitiv Real-Time Advanced Distribution Server) to which the EMA connects. This is for setting values of the node. This value can be a remote host name or IP address.
    	
            

<Channel>

            <Name value="Channel_1"/>                                               

            <ChannelType value="ChannelType::RSSL_SOCKET"/>                                                                         

            <CompressionType value="CompressionType::None"/>

            <GuaranteedOutputBuffers value="5000"/>

            <ConnectionPingTimeout value="30000"/>

            <TcpNodelay value="1"/>

 

            <Host value="[Your Refinitiv Real-Time Advanced Distribution Server HOST]"/>

            <Port value="[Your Refinitiv Real-Time Advanced Distribution Server RSSL Port]"/>

      </Channel>

3.    You can change the requested service and item name in the following line of code to match your environment

    	
            
consumer.registerClient(EmaFactory.createReqMsg().serviceName("<service>").name("<item name>").interestAfterRefresh(false).payload(view), appClient);

4.    Build the application with ant command. All application class files will be available at "out" folder, the EmaConfig.xml also copied to the out folder automatically.

    	
            
$>ant build

5.    Stay in the same location, run the application with the following command

    	
            
java -cp out;lib/* com.refinitiv.platformservices.article.ExchangeName

6.    The example output when you run the application for each item name:

    	
            

//IBM.N

Item Name: IBM.N

 Service Name: ELEKTRON_DD

Item State: Non-streaming / Ok / None / 'All is well'

Fid: 3 Name = DSPLY_NAME DataType: Rmtes Value: INTL BUS MACHINE

Fid: 22 Name = BID DataType: Real Value: 0.0

Fid: 25 Name = ASK DataType: Real Value: 0.0

Fid: 1709 Name = RDN_EXCHD2 DataType: Enum Value: NYS //FID value: 2          "NYS"   New York Stock Exchange

 

//HSBA.L

Item Name: HSBA.L

Service Name: ELEKTRON_DD

Item State: Open / Ok / None / 'All is well'

Fid: 3 Name = DSPLY_NAME DataType: Rmtes Value: HSBC HOLDINGS

Fid: 22 Name = BID DataType: Real Value: 642.8

Fid: 25 Name = ASK DataType: Real Value: 642.9

Fid: 1709 Name = RDN_EXCHD2 DataType: Enum Value: LSE //FID value: 64        "LSE"   London Stock Exchange

 

//PTT.BK

Item Name: PTT.BK

Service Name: ELEKTRON_DD

Item State: Non-streaming / Ok / None / 'All is well'

Fid: 3 Name = DSPLY_NAME DataType: Rmtes Value: PTT

Fid: 22 Name = BID DataType: Real Value: 35.25

Fid: 25 Name = ASK DataType: Real Value: 35.5

Fid: 1709 Name = RDN_EXCHD2 DataType: Enum Value: SET //FID value: 158        "SET"   The Stock Exchange of Thailand

Conclusion

If your application subscribes to data from Refinitiv Real-Time Infrastructure and you need an exchange information, you can get it from the FID 1709 (RDN_EXCHD2). The EMA Java API (version 3.1.0 and above) can help an application consume and parse this FID to get an exchange short name with only a few lines of code.

References

For further details, please check out the following resources:

For any question related to this article or Enterprise Message API page, please use the Developer Community Q&A Forum.

DOWNLOADS

Article.EMA.Java.ExchangeShortName