Skip to content

Get required details

kncsolutions edited this page Aug 20, 2018 · 20 revisions

To extract data in filtered way, certain details are necessary. E.g. to extract the listed instruments for an exchange in a filtered way, you have to pass certain optional parameters.
In this section, the guidelines to extract the valid values for optional parameters is described.

Table of Contents
  1. Get Instrument Types
  2. Get Products
  3. Get Expiry Dates
  4. Get Option Types
  5. Get Strike Prices

Get Instrument Types

The instruments listed in an exchange might have **instrument type ** associated with it.E.g. OPTIDX, FUTIDX. To get the list of valid instrument types call the following method:

public InstrumentTypesResponse getInstumentTypes(String exchange) {
......
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.

Example(A)

GfeedClient gc=new GfeedClient("WEB_SOCKET_ENDPOINT_URL","API_KEY");
...................................................
InstrumentTypesResponse response=gc.getInstumentTypes("NFO");
System.out.println(response.instrumentTypes.get(0).instrumentType);

The response structure

The getInstumentTypes(<exchange>) method returns InstrumentTypesResponse. It contains the following information:

  1. InstrumentTypeRequest instrumentsTypeRequest
  2. List<InstrumentTypes> instrumentTypes
    It is the collection of items of InstrumentTypes type. Each item in the collection may contain the following fields.
Variable Name Type
instrumentType String
  1. String message
    For a valid response the message must be equal to Constants.INSTRUMENT_TYPES_RESULT_MESSAGE.
    [Go to Top]

Get Products

To get the products for an exchange(e.g NIFTY) use the following methods:
** To get all the products:

public ProductResponse getProducts(String exchange) {
..............
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.

    ** To get the product filtered by instrument type:
public ProductResponse getProducts(String exchange,Map<String,String> optionalParams) {
....
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.
  • params :
    For the map which has to be passed as argument, the Keys of the <key,value> pairs are constants and predefined.
    The list of supported <key,value> pair:
    <Constants.INSTRUMENT_TYPE_KEY,instrumentType>
    The value of instrumentType must be from the list of exchanges which you can get by calling the getInstrumentTypes(..) method.

Example(B)

GfeedClient gc=new GfeedClient("WEB_SOCKET_ENDPOINT_URL","API_KEY");
...................................................
ProductResponse response1=gc.getProducts("NFO");
System.out.println(response1.products.get(0).product);
..................................................
Map<String,String> op=new HashMap<String,String>();
op.put(Constants.INSTRUMENT_TYPE_KEY,"FUTIDX");
ProductResponse response2=gc.getProducts("NFO",op);
System.out.println(response2.products.get(0).product);

The response structure

The getProducts(...) methods returns ProductResponse. It contains the following information:

  1. ProductRequest request
  2. List<Products> products
    It is the collection of items of Products type. Each item in the collection may contain the following fields.
Variable Name Type
product String
  1. String message
    For a valid response the message must be equal to Constants.PRODUCT_RESULT_MESSAGE.
    [Go to Top]

Get Expiry Dates

To get the expiry dates for different products of an exchange use the following methods:
** To get the expiry dates of all the products:

public ExpiryDateResponse getExpiryDates(String exchange) {
.................
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.

    ** To get the filtered expiry dates:
public ExpiryDateResponse getExpiryDates(String exchange,Map<String,String> optionalParams) {
....
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.
  • optionalParams :
    For the map which has to be passed as argument, the Keys of the <key,value> pairs are constants and predefined.
    The list of supported <key,value> pair:
    <Constants.INSTRUMENT_TYPE_KEY,instrumentType>
    The value of instrumentType must be from the list of instrumentTypes which you can get by calling the getInstrumentTypes(..) method.
    <Constants.PRODUCT_TYPE_KEY,product>
    The value of product must be from the list of products which you can get by calling the getProducts(..) method.

Example(C)

GfeedClient gc=new GfeedClient("WEB_SOCKET_ENDPOINT_URL","API_KEY");
...................................................
ExpiryDateResponse response1=gc.getExpiryDates("NFO");
System.out.println(response2.dates.get(0).expirydate);
..................................................
Map<String,String> op=new HashMap<String,String>();
op.put(Constants.INSTRUMENT_TYPE_KEY,"FUTIDX");
ProductResponse response2=gc.getProducts("NFO",op);
System.out.println(response2.dates.get(0).expirydate);

The response structure

The getExpiryDates(...) methods returns ExpiryDateResponse. It contains the following information:

  1. ExpiryDateRequest request
  2. List<ExpiryDate> dates
    It is the collection of items of ExpiryDate type. Each item in the collection may contain the following fields.
Variable Name Type
expirydate String
  1. String message
    For a valid response the message must be equal to Constants.EXPIRY_DATE_RESULT_MESSAGE.
    [Go to Top]

Get Option Types

To get the option types available use the following methods:
** To get all the option types for an exchange:

public OptionTypeResponse getOptionTypes(String exchange) {
...........................
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.

    ** To get the filtered option types:
public OptionTypeResponse getOptionTypes(String exchange,Map<String,String> optionalParams) {
	..................
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.
  • optionalParams :
    For the map which has to be passed as argument, the Keys of the <key,value> pairs are constants and predefined.
    The list of supported <key,value> pair:
    <Constants.INSTRUMENT_TYPE_KEY,instrumentType>
    The value of instrumentType must be from the list of instrumentTypes which you can get by calling the getInstrumentTypes(..) method.
    <Constants.PRODUCT_TYPE_KEY,product>
    The value of product must be from the list of products which you can get by calling the getProducts(..) method.
    <Constants.EXPIRY_DATE_KEY,expirydate>
    The value of expirydate must be from the list of expirydates which you can get by calling the getExpiryDates(..) method.

Example(D)

GfeedClient gc=new GfeedClient("WEB_SOCKET_ENDPOINT_URL","API_KEY");
...................................................
OptionTypeResponse response1=gc.getOptionTypes("NFO");
System.out.println(response1.optionType.get(0).type);
..................................................
Map<String,String> op=new HashMap<String,String>();
op.put(Constants.INSTRUMENT_TYPE_KEY,"FUTIDX");
op.put(Constants.PRODUCT_KEY,"BANKNIFTY");
op.put(Constants.EXPIRY_DATE_KEY,"30AUG2018");
OptionTypeResponse response2=gc.getOptionTypes("NFO",op);
System.out.println(response1.optionType.get(0).type);

The response structure

The getOptionTypes(...) methods returns OptionTypeResponse. It contains the following information:

  1. OptionTypeRequest request
  2. List<OptionType> optionType
    It is the collection of items of OptionType type. Each item in the collection may contain the following fields.
Variable Name Type
type String
  1. String message
    For a valid response the message must be equal to Constants.OPTION_TYPE_RESULT_MESSAGE.
    [Go to Top]

Get Strike Prices

To get all the strike prices use the following methods:
** To get all the option types for an exchange:

public StrikePriceResponse getStrikePrices(String exchange) {
..............................
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.

    ** To get the filtered option types:
public StrikePriceResponse getStrikePrices(String exchange,Map<String,String> optionalParams) {
	...................
}

The necessary parameter:

  • exchange : The value must be from the list of exchanges which you can get by calling the getSubscribedExchanges() method.
  • optionalParams :
    For the map which has to be passed as argument, the Keys of the <key,value> pairs are constants and predefined.
    The list of supported <key,value> pair:
    <Constants.INSTRUMENT_TYPE_KEY,instrumentType>
    The value of instrumentType must be from the list of instrumentTypes which you can get by calling the getInstrumentTypes(..) method.
    <Constants.PRODUCT_TYPE_KEY,product>
    The value of product must be from the list of products which you can get by calling the getProducts(..) method.
    <Constants.EXPIRY_DATE_KEY,expirydate>
    The value of expirydate must be from the list of expirydates which you can get by calling the getExpiryDates(..) method.
    <Constants.OPTION_TYPE_KEY,optiontype>
    The value of optiontype must be from the list of option types which you can get by calling the getOptionTypes(..) method.

Example(E)

GfeedClient gc=new GfeedClient("WEB_SOCKET_ENDPOINT_URL","API_KEY");
...................................................
StrikePriceResponse response1=gc.getStrikePrices("NFO");
System.out.println(response1.prices.get(0).strikeprice);
..................................................
Map<String,String> op=new HashMap<String,String>();
op.put(Constants.INSTRUMENT_TYPE_KEY,"FUTIDX");
op.put(Constants.PRODUCT_KEY,"BANKNIFTY");
op.put(Constants.EXPIRY_DATE_KEY,"30AUG2018");
op.put(Constants.OPTION_TYPE_KEY,"CE");
StrikePriceResponse response2=gc.getStrikePrices("NFO",op);
System.out.println(response1.prices.get(0).strikeprice);

The response structure

The getStrikePrices(...) methods returns StrikePriceResponse. It contains the following information:

  1. StrikePriceRequest request
  2. List<StrikePrice> prices
    It is the collection of items of StrikePrice type. Each item in the collection may contain the following fields.
Variable Name Type
strikeprice String
  1. String message
    For a valid response the message must be equal to Constants.STRIKE_PRICES_RESULT_MESSAGE.
    [Go to Top]