Using RDP Symbology Conversion Service with .NET Core
Introduction
Symbology Conversion service is one of the REST API provided under the Refinitiv Data Platform (RDP). It leverages existing services that underly Refinitiv products, to create an aggregated list of functionality needed in the Symbology service. The Conversion method allows users to convert identifiers from one type to another. For example, the user can use the Conversion method to convert ISIN or CUSIP to Refinitiv RIC with additional information about the company.
There are two parts in this article the first part is detailed about the Symbology Conversion method including details about the request and response message for the Conversion service. The second part is the details about the .NET Core Console example application we create to demonstrate the Symbology API usage.
Prerequisites
- Understand the concepts of RDP and basic usage of the Authorization services. Please find more details from Developer Portal.
Required software components:
- .NET Core Framework version 2.2 or later version
- Visual Studio 2017- We use Visual Studio 2017 to develop the application on Windows.
Optional software components:
- Visual Studio Code - IDE for .NET Core development on Windows and Mac OS.
- Other IDE's such as Rider - IDE provided by Jetbrain for .NET Core projects on Mac OS.
Symbology Convert Method
The symbology convert method supports two ways of converting and retrieving symbology data:
1. With no specified list of return fields.
2. With a specified list of return fields.
Parameters
The convert method takes two parameters:
- Universe (required): This takes a comma-separated list of input symbols or identifiers. Currently, the maximum input symbols in the list are 100 items.
- To (optional): This takes a comma-separated list of return fields. If not specified the convert method returns all matching return fields. Please refer to the APIDocs page for the available field list and JSON schema for the service.
Model
Below is a model of a GET Request and Post Request message. Note that the endpoint we use in this article based on the beta version of the RDP.
GET REQUEST
POST REQUEST
Conversion with No Field List
When no field list is specified for the To parameter the convert method converts a symbol and returns all existing symbol types and reference data fields. Below is a sample of both a Get request and a Post request with no specified field list. Note that the Url endpoint provided based on a beta version of the service can be changed in the future after released.
GET REQUEST Sample
POST REQUEST Sample
Conversion with Specified Field List
When a field list is specified for the To parameter the convert method converts a symbol and returns only the requested fields. Below is a sample of both a Get request and a Post request. When the To parameter has specified fields only matched fields will be returned.
GET REQUEST Sample
POST REQUEST Sample
Symbology Response Instrument Field
Basically, the collection format of the Conversion response is Comma-separated values(CSV) according to Swagger JSON scheme for Symbology Convert from the APIDocs website.
The following JSON data is a sample of the response message from the Convert method. Please refer to a full JSON scheme for an additional field provided by the service.
JSON Response Message Sample
The response of the convert method containing a JSON object named data and headers. Actually, the data object is a collection or list of the array of nullable dynamic types. The array is actual data for each input instrument or symbol in the request message. And the header object is a collection of header objects describing the meaning of elements inside the array.
For example, from the sample response message, the data[1] represents actual data for instrument "TRI.N" and the value of data[1][2] is a string "CA8849037095" which represents an ISIN according to the value of headers[2].title.
The order of array inside the data associated with the order of an element in headers object. Hence, the application has to iterate through the data collection to get the value of each symbol identifier. And then get the data definition for each element in the array by parsing the headers object to get the header description and its title.
The response always includes a collection of the universe from the request message. It also has a field called Instrument which returns the input identifier requested in the universe parameter.
Coding with .NET Core
This section describing the implementation of .NET Core example which is a console application we create to demonstrate the usage of the Symbology convert method.
Create a Data Model
Basically, RDP provides the Swagger JSON scheme on the APIDocs website. The developer can download the JSON scheme and use it as a reference to create a request and response message. The JSON scheme also describes the data model used by the services. The below screenshot is the Symbology service Swagger page.
There are two steps the example used to request data from the Symbology Conversion service.
1. Get Access Token from EDS Authentication Service as described in the following Page.
2. Create JSON request body for Symbology convert method and then pass it to HttpClient class with the Access Token. And then send HTTP GET or Post to Symbology Conversion endpoint.
This example uses the JSON scheme from Authentication service and Symbology Conversion service to generate data models in the .NET Core application. The example uses NSwagStudio tool to generate CSharp Client and data models from the JSON Scheme files.
Basically, the output from the NSwageStudio is a C# client class with a Data Models and its Enum values. The client classes basically provide an interface for an application to request and manage the response. The client class uses a NewtonSoft JSON library to handle the JSON data. It can use the JSON library to serialize the object to JSON request and deserialize the response back to the Symbology object. The NSwagStudio automatically generates .NET async method for retrieving the data using Http Get or Http Post. Please refers to the instruction for using the NSWagStudio application from NSWagStudio GitHub page. Note that after generating the client class from the JSON scheme, you might need to refactor the codes and modify the class name and enum value yourself to match with your application design.
Interface and Class for EDS Authentication
This example uses the Swagger JSON scheme to generate a client class for EDS Authentication.
The following class and interface were generated by NSWagStudio and it has been modified to use with the EDS Authentication service and Symbology Conversion service.
IAuthorizeClient provides the TokenAsync method for retrieving Token from the server.
Tokenresponse returns when an application calls TokenAsync to get Access Token. All class members represent the Token data.
Interface and Class for Symbology Conversion
IEDPSymbologyClient is an interfaces provide async methods for using HttpGet(GetConvertAsync) and HttpPost(GetConvertAsync) with the Symbology Conversion service. There is the ConvertRequest class the application used to pass a request message to the convert methods. The application will convert the class to JSON request body by serializing the ConvertRequest object to JSON data.
NSWagStudio also generates Symbology class which is a Data Model for Symbology response data. The GetConvertAsync and PostConvertAsync will return Symbology object to the application. It has to use the Newtonsoft JSON library to deserialize the JSON response message to Symbology object. The application has to parse the data object and the headers from the Symbology object. We need to change the Data Property to use dynamic type to support various type including a null value.
Input
An example is a console-based application. There are two options for the user to specify the symbol/identifier list with custom fields for the request message.
- Specify an identifier list with required fields via a command-line argument.
- A user can create a JSON file containing a request message and then pass a file path to the command-line argument. Then the application will create a request using parameters from the JSON file instead.
At the beginning of the application, the user has to enter the username and password. Then the application will pass it to Authentication service to get a new Access Token.
Output
For the output, the example will print the headers and their data to console output. The example also writes the data to a CSV file named "csvoutput.csv" by default.
Usage
The following list is the command line options generated by the application. It uses C# Commandline Parser to generate the help page and manage the command line arguments. There are sample usage and options that the user can specify when running and setting the command line argument. Note that if you have to connect to the RDP Server through your proxy server you might need to specify the proxy server using --proxy command line option.
Compile and Build the example application
You can download the application from Github and then compile and build it on Windows, Linux or macOS according to .NET Core supported platform. You have to install .NET Core SDK 2.x and then open solution file edpapi.sln with Visual Studio 2017. Or you can compile and build the example using dotnet build or publish the project using dotnet publish command.
You can follow the following step to publish the example project.
1.) Clone edpapi project from GitHub.
2.) Go to folder EDPSymbologyConvertConsoleApp
3.) Running dotnet publish command to publish the project to the native executable file and then you can run the executable file directly without using dotnet command on .Net Core supported OS. You can also share the app to another PC which runs the same OS by copying all files under the publish folder.
Please find more details about the dotnet publish command from MSDN Document.
The below sample is a command to publish a self-contained .NET core executable file on Linux Ubuntu. It will generate execute files including required DLLs in the publish folder. For another OS you can change linux-x64 to a new one and you can find the list from rid-catalog page.
You should see the console output like the following sample output and you can find execute file under publish directory.
The publish command generates an application named EDPSymbologyConvert under the folder "/publish".
Running the example
To test the example you must have a valid username and password with permission to access Symbology Conversion service.
The following command used to request the data for RIC IBM.N, CUSIP 037833100 and ISIN TH0001010014. A user may use -o to specify a new CSV file name to save the data.
A user may also use --verbose to print additional output such as the JSON request and response.
The below sample is output when you run the command line. It will return three sets of the array inside the data object. Each element inside the array is field value for the fields the application request from the server. In this case, it returns all available fields because the user does not specify the fields list.
Summary
This article explains the usage of the Symbology Conversion service. It also provides an example application to demonstrate the usage of the Authentication and Symbology convert method. The example can convert a symbol or list of symbols to a specified output type. RDP API users can use the example application to test the service and apply the codes from the example with another service on the RDP.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Authors
- Moragodkrit Chumsri - Release 1.0. Initial work
License
This project is licensed under the MIT License - see the LICENSE file for details