DataScope Select - REST API

Close Menu
Expand All Collapse All
Introductory Tutorials Tutorials Introduction Programming without SDK Tutorial REST API Tutorials REST API Tutorials Introduction REST API Tutorial 1: Connecting to the DSS server REST API Tutorial 2: On Demand End of Day Extraction REST API Tutorial 3: On Demand intraday extraction, embargo REST API Tutorial 4: On Demand price history extraction REST API Tutorial 5: On Demand corporate actions extraction REST API Tutorial 6: On Demand ownership data extraction REST API Tutorial 7: On Demand T&C extraction REST API Tutorial 8: On Demand composite extraction REST API Tutorial 9: On Demand extraction: instrument list REST API Tutorial 10: GUI control calls: immediate extract REST API Tutorial 11: Search by Instrument REST API Tutorial 12: Search for an Equity REST API Tutorial 13: Search for a Future or Option REST API Tutorial 14: On Demand price history extraction raw .Net SDK Tutorials .Net SDK Tutorial 1: Connecting to the DSS server .Net SDK Tutorial 2: GUI control calls: List, report, sched .Net SDK Tutorial 3: GUI control calls: Validate, extraction .Net SDK Tutorial 4: GUI control calls: Embargo, note files .Net SDK Tutorial 5: On Demand: EoD extraction .Net SDK Tutorial 6: On Demand: EoD extraction, file I/O .Net SDK Tutorial 7: On Demand: large instrument lists .Net SDK Tutorial 8: On Demand: Terms & Conditions .Net SDK Tutorial 9: On Demand: Composite extraction .Net SDK Tutorial 10: Search by Instrument .Net SDK Tutorial 11: Search for Equity .Net SDK Tutorial 12: Search for Future or Option

.Net SDK Tutorial 11: Search for Equity

Last update July 2019
Environment Windows
Language C#
Compilers Microsoft Visual Studio 2012/2013
Prerequisites DSS login, internet access, having done the previous tutorials
Source code Download .Net SDK Tutorials Code

Tutorial purpose

This is the eleventh tutorial in a series of .Net SDK tutorials. It is assumed that the reader has acquired the knowledge delivered in the previous tutorials before following this one.

This tutorial is the second covering searches. It explains how to make a search request for an equity instrument code, using as criteria the exchange and the ticker (other criteria are also available and briefly explained).

 

Table of contents

 

Getting ready

Opening the solution

The code installation was done in Tutorial 1.

Opening the solution is similar to what was done in the previous tutorials:

  • Navigate to the \DSS REST API\Tutorial 11\Learning folder.
  • Double click on the solution file rest_api_equity_search.sln to open it in Microsoft Visual Studio.

 

Referencing the DSS SDK

Before anything else, you must reference the DSS REST API .Net SDK in the Microsoft Visual Studio project.

Important: this must be done for every single tutorial, for both the learning and refactored versions.

This was explained in the tutorial 2; please refer to it for instructions.

 

Viewing the C# code

In Microsoft Visual Studio, in the Solution Explorer, double click on Program.cs and on DssClient.cs to display both file contents. Each file will be displayed in a separate tab.

 

Setting the user account

Before running the code, you must replace  YourUserId  with your DSS user name, and  YourPassword  with your DSS password, in these 2 lines of Program.cs:

        private static string dssUserName = "YourUserId";
        private static string dssUserPassword = "YourPassword";

Important reminder: this must be done for every single tutorial, for both the learning and refactored versions.

Failure to do so will result in an error at run time (see Tutorial 1 for more details).

 

Understanding the code

We shall only describe what is new versus the previous tutorials.

DssClient.cs

This is the same as the version of Tutorial 10, except for the leading comment.

Again, we shall use a search context.

 

Program.cs

Performing the search

The code performs a search based on a set of exchange codes and a ticker, and sets a limit to the number of records in the result:

searchContext.Preferences.MaxPageSize = 100;
IDssEnumerable<EquitySearchResult> resultingInstruments =
    searchContext.EquitySearch(
        EquitySearchRequest.Create(
            null,                    //Sub types
            null,                    //Asset categories
            null,                    //Company name
            null,                    //Currency codes
            null,                    //Description
            null,                    //Domiciles codes
            null,                    //Fair value indicator
            new [] { "PAR", "SWX" }, //Exchange codes
            null,                    //GICs codes
            null,                    //File codes
            null,                    //Org identifier
            EquityStatus.Active,     //Asset status
            "UG",                    //Ticker
            IdentifierType.Ric,      //Identifier type
            null,                    //Identifier
            IdentifierType.Ric));    //Preferred identifier type

Note: contrary to the other search calls, the result is not a ValidatedInstrument, instead it is an EquitySearchResult.

 

Search criteria

When creating the search request, many parameters can be set (or left blank). They are, in this order:

Sub types: defines the instrument sub type. Currently it only supports a single value. Example for ordinary shares:

new[] { "ODSH" },

Asset categories. Currently it only supports a single value. Example for ordinary:

new[] { "ORD" },

Company name. A match occurs as long as the company name starts with the parameter value. It is case insensitive.

As an example, the following will match any company name starting with “Peu”, like Peugeot:

"Peu",

Currency codes. Currently it only supports a single value. Example:

new[] { "EUR" },

Description. A match occurs as long as the description starts with the parameter value. It is case insensitive.

As an example, the following will match any company description starting with “Peu”, like PEUGEOT ORD:

"Peu",

Domicile codes: these are 2 letter country codes. Currently it only supports a single value. Example for France:

new[] { "FR" },

Fair value indicator. Possible values: Yes or No (or null). Example:

FairValueIndicator.Yes,

Exchange codes: three letter codes. Supports multiple values. Example:

new [] { "PAR", "SWX" },

GicsCodes. Supports multiple values. Example:

new[] { "25102010", "25102020" },

File codes: define sets of instruments. Supports multiple values. Example for TLX/Euro TLX Equities:

new[] { "1305" },

Organisation Identifier. Example:

"18175,18174"

Asset status. Possible values: Active or inactive. Example:

EquityStatus.Active,

Ticker. Example:

"UG, IB",

Identifier type (ChainRIC, Ric, Isin, Cusip, Sedol, etc.). Example:

IdentifierType.Ric,

Identifier. It can include a * as wildcard. Example:

"PEU*",

Preferred identifier type for the result. Example:

IdentifierType.Ric));

For a more detailed description of all parameters, see the REST API Reference Tree.

Feel free to experiment with them to get a better feeling of the equity search possibilities.

 

Displaying the results

The result contains details on each returned instrument. The code is very similar to that of the previous tutorial (except that we must use an EquitySearchResult instead of a ValidatedInstrument). It displays some details, and the number of results.

foreach (EquitySearchResult instrument in resultingInstruments)
{
    Console.WriteLine("{0}\n - IdentifierType: {1}\n - InstrumentType: {2}\n - Source: {3}\n - Status: {4}\n - Description: {5}",
        instrument.Identifier,
        instrument.IdentifierType, instrument.InstrumentType,
        instrument.Source, instrument.Status, instrument.Description);
}
int numberOfResults = resultingInstruments.Count();
Console.WriteLine("\nNumber of results: {0}", numberOfResults);

 

Full code

The full code can be displayed by opening the appropriate solution file in Microsoft Visual Studio.

 

Summary

List of the main steps in the code:

  1. Authenticate by creating a search context.
  2. Run the search, wait for it to complete.
  3. Treat the returned data.

 

Refactored version

There is none for this tutorial.

 

Code run results

Build and run

Don’t forget to reference the DSS SDK, and to set your user account in Program.cs !

 

Successful run

After running the program, and pressing the Enter key when prompted, the final result should look like this:

 

Potential errors and solutions

If the user name and password were not set properly, an error will be returned. See Tutorial 1 for details.

 

Conclusions

This tutorial introduced the equity search, and described the available search criteria.

Now move on to the next tutorial, which covers another search type.

Tutorial Group: 
.Net SDK Tutorials