For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
1 0 1 1

How to construct Bond's 10 year Yield Series through Python API

Hi, I want to construct a 10 year worth of data yield timeseries of a number of cash bonds (say 10 year US Gov Bond for sake of example). I have the ISINs in a spreadsheet and have been able to map them with RICs in Datascope Select. Is there a Python API I could use to import such RICs and build my timeseries? Or even better, in order to by-pass the ISIN-RIC mapping in Datascope for future instruments (say I want to *always* select =RRPS RICs across all ISINs for example), can I directly build my timeseries doing such bulked search in a Python script? Thank you

datascope-selectricsbondsisintimeseries
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
45.2k 103 43 60

@andrea.concas

You can use the ISINs in the request message. For example:

            "InstrumentIdentifiers": [
                {
                    "Identifier": "US4592001014",
                    "IdentifierType": "Isin"
                }

To extract data from DSS you need to know the following things.

1. The instrument identifiers. It could be the ISINs or RICs. You already have it

2. The report template and the fields in the report template that can provide the required data. You can search for available fields in the following documents.

Then, you construct the request message to extract the data.

In your case, it could be the "Bid Yield" field in the Price History DSS template.

The request looks like this:

{
  "ExtractionRequest": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.PriceHistoryExtractionRequest",
    "ContentFieldNames": [
      "File Code",
      "RIC",
      "Trade Date",
      "Bid Yield"        
    ],
    "IdentifierList": {
      "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",  
      "InstrumentIdentifiers": [   
      { "Identifier": "US10YT=RRPS", "IdentifierType": "Ric" }

      ],
      "ValidationOptions": { "AllowHistoricalInstruments": true },
      "UseUserPreferencesForValidationOptions": false
    },
    "Condition": {
      "AdjustedPrices": true,
      "QueryStartDate": "2021-07-24T00:00:00.000Z",
      "QueryEndDate": "2021-09-30T00:00:00.000Z"
    }
  }
}

The endpoint is https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions//ExtractWithNotes.

The output is:

{
    "@odata.context": "https://selectapi.datascope.refinitiv.com/RestApi/v1/$metadata#DataScope.Select.Api.Extractions.ExtractionRequests.ExtractionResult",
    "Contents": [
        {
            "IdentifierType": "Ric",
            "Identifier": "US10YT=RRPS",
            "File Code": null,
            "RIC": "US10YT=RRPS",
            "Trade Date": "2021-07-26",
            "Bid Yield": 1.276232
        },
        {
            "IdentifierType": "Ric",
            "Identifier": "US10YT=RRPS",
            "File Code": null,
            "RIC": "US10YT=RRPS",
            "Trade Date": "2021-07-27",
            "Bid Yield": 1.234427
        },

You can refer to the Python examples in the following links:

You can also refer to the REST API tutorial.

You may need to contact the DataScope support team via MyRefinitiv to verify the report template and fields.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
18.1k 21 12 20

From @Jirapongse 's answer.

Step 1 - You can follow this code to get DSS token with your dss username and password.

import requests
import json

url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Authentication/RequestToken"

payload = json.dumps({
  "Credentials": {
    "Username": "9001609",
    "Password": "xxxxxYOURDSSPASSWORDxxxxx"
  }
})
headers = {
  'Prefer': 'respond-async',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)
token = json.loads(response.text)['value']
print(token)


Step 2 - request for the data

url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractWithNotes"

payload = json.dumps({
  "ExtractionRequest": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.PriceHistoryExtractionRequest",
    "ContentFieldNames": [
      "File Code","RIC","Trade Date","Bid Yield"
    ],
    "IdentifierList": {
      "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
      "InstrumentIdentifiers": [
        {
          "Identifier": "US10YT=RR",
          "IdentifierType": "Ric"
        }
      ],
      "ValidationOptions": {
        "AllowHistoricalInstruments": True
      },
      "UseUserPreferencesForValidationOptions": False
    },
    "Condition": {
      "AdjustedPrices": True,
      "QueryStartDate": "2011-07-24T00:00:00.000Z",
      "QueryEndDate": "2021-07-30T00:00:00.000Z"
    }
  }
})
headers = {
  'Prefer': 'respond-async',
  'Content-Type': 'application/json',
  'Authorization': 'Token '+token
}

response = requests.request("POST", url, headers=headers, data=payload)
responseJSON = json.loads(response.text)

Please note that these codes are provided as an example only.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.