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
Best Answer
-
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.
0
Answers
-
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.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 690 Datastream
- 1.4K DSS
- 629 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 559 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 279 Open PermID
- 45 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 716 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 106 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 95 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛