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 12: Search for Future or Option

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 twelfth 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 third covering searches. It explains how to make a search request for a future or option instrument code, using as criteria the strike price and expiration date (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 12\Learning folder.
  • Double click on the solution file rest_api_future_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 that of the two preceding tutorials, except for the leading comment.

Again, we shall use a search context.

 

Program.cs

Performing the search

The code performs a search based on an underlying RIC, strike price and maturity date, and sets a limit to the number of records in the result:

searchContext.Preferences.MaxPageSize = 100;
DateTimeOffset expiryDate = DateTimeOffset.Parse("2016-12-31T00:00:00.000Z");
IDssEnumerable<FuturesAndOptionsSearchResult> resultingInstruments =
    searchContext.FuturesAndOptionsSearch(
        FuturesAndOptionsSearchRequest.Create(
            null,                    //Futures and Options Type
            null,                    //Put Call
            null,                    //File Codes
            "ED",                    //Underlying RIC
            null,                    //Exersize Style
            null,                    //Currency Code
            null,                    //Description
            null,                    //Exchange codes
            NumericRangeComparison.CreateNumericRangeComparison(85,88),  //Strike Price
            DateValueComparison.CreateDateValueComparison(ComparisonOperator.GreaterThanEquals,
                                                          expiryDate),  //Expiration Date
            FuturesAndOptionsStatus.Active,  //Asset status
            IdentifierType.Ric,      //Identifier type
            "ED*",                   //Identifier
            IdentifierType.Ric));    //Preferred identifier type

 

Search criteria

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

Futures and Options types. Possible values: Futures, FuturesOnOptions, Options. Example:

FuturesAndOptionsType.Options,

Put Call. Possible values: Put, Call. Example:

PutCall.Put,

File codes: define sets of instruments. Supports multiple values. Example for Austrian futures:

new[] { "5054", "5451" },

Underlying RIC. Example:

"ED",

Exercise Style: American or European. Example:

ExerciseStyle.American,

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

new[] { "USD" },

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 “Ed Jan”, like ED Jan9 85.0 P:

"Ed Jan",

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

new [] { "ASQ", "NSI", "NYM" },

Strike price. This can be defined as a numeric range or value comparison. Two examples:

NumericRangeComparison.CreateNumericRangeComparison(85,88),
NumericValueComparison.CreateNumericValueComparison(ComparisonOperator.Equals, 85),

Expiration date. This can be defined as a date range or value comparison. Two examples:

DateRangeComparison.CreateDateRangeComparison(startDate, EndDate),
DateValueComparison.CreateDateValueComparison(ComparisonOperator.GreaterThanEquals, expiryDate),

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

EquityStatus.Active,

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

IdentifierType.Ric,

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

"ED*",

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 practically the same as that of the previous tutorial, it displays some details, and the number of results.

foreach (FuturesAndOptionsSearchResult 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:

This goes on (there are many results). The end looks like this:

Note: the limit we set to the size of the result set (100 records) was not hit.

 

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 presented the future and option search, and described the available search criteria.

Tutorial Group: 
.Net SDK Tutorials