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
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛