How to deal with stocks that changed their names in DSWS
I’ve got an issue where I can’t return these DataStream datapoints for changed Sedols (due to corporate actions), could you help?
So, for example, RBS.L (sedol B7T7721) was a ticker on the LondonStockExchange, but around 21/Jul/2020 I it changed to NWG.L (sedol BM8PJY7)
When I run the DataStream with the old sedol for a historic date, I get ‘$$ER: E100,INVALID CODE OR EXPRESSION ENTERED’:
dsFields = ['DPL#(PCH#(X(RI),1D),8)','DPL#((LAG#(X(LI#RI),-6M)/X(LI#RI))-1,8)']
i1 = ds.get_data(tickers="UKB7T7721", fields=dsFields, kind=1, start="20200415", end="20200416", freq="D")
When I run the DataStream with the new sedol for a historic date, I do get correct values returned:
dsFields = ['DPL#(PCH#(X(RI),1D),8)','DPL#((LAG#(X(LI#RI),-6M)/X(LI#RI))-1,8)']
i1 = ds.get_data(tickers="UKBM8PJY7", fields=dsFields, kind=1, start="20200415", end="20200416", freq="D")
My question is, do you know of a way I can either
- Call the Python get_data request with a flag to consider redundant Sedols as well?
- Or some separate DataStream/DataScope call to get the current correct Sedol for a redundant Sedol?
Best Answer
-
Thanks for reaching out to us.
I cannot find a flag in the get_data method to consider redundant SEDOLs. However, you need to contact the Datastream support team via MyRefinitv to confirm it.
I can use the HistoricalReferenceExtractionRequest in Refinitiv Tick History to get the current SEDOL. For example, the request looks like this:
{
"ExtractionRequest": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.HistoricalReferenceExtractionRequest",
"ContentFieldNames": [
"RIC", "CUSIP", "ISIN", "SEDOL", "Issuer OrgID", "Exchange Code", "Currency Code", "Change Date"
],
"IdentifierList": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
"InstrumentIdentifiers": [
{ "Identifier": "B7T7721", "IdentifierType": "Sedol" }
],
"ValidationOptions": {"AllowHistoricalInstruments": true},
"UseUserPreferencesForValidationOptions": false
},
"Condition": {
"ReportDateRangeType": "Range",
"QueryStartDate": "2022-01-01",
"QueryEndDate": "2022-09-01"
}
}
}The response contains the following entries.
{
"IdentifierType": "Sedol",
"Identifier": "B7T7721",
"RIC": "NWG.L",
"CUSIP": null,
"ISIN": "GB00BM8PJY71",
"SEDOL": "BM8PJY7",
"Issuer OrgID": "13709",
"Exchange Code": "LSE",
"Currency Code": "GBp",
"Change Date": "2022-08-30"
},0
Answers
-
I see thanks again Jira. So that means in Datascope, I can request and confirm current SEDOL based on old SEDOL? (So use old SEDOL as the identifier type, and ask for SEDOL under extraction request?)
One more question would be - does this mean I would need to have an IF logic and if there's any issues, then run extract the new SEDOL? Thanks in advance Jira!
0 -
Yes, the historical reference template can get a new SEDOL based on an old SEDOL.
It is correct. You can have an IF login to find a new SEDOL. You can use Refintiv Tick History or other APIs.
I found that we can also use the RDP Search or Symbology API to get a new SEDOL.
0 -
Great stuff Jira. Sorry really one last question. So if user is exrtracting data from DSWS, but just needs get the new SEDOL using old SEDOL within his DSWS python code, is there a way to embed just this part into his current DSWS Python code?
(Assuming his company subscribes to DSS)
I guess in other words, can you mix DSS REST API (I think it's what this is right?) and DSWS Python in one code execution....
Promise this is the last question. Thanks so much!
0 -
HistoricalReferenceExtractionRequest is the RTH template, not DSS. Therefore, the client must have an access to RTH.
Yes, the client can embed the RTH code into the current DSWS python code.
The code could look like this:
import requests
import json
import time
import pandas as pd
def get_new_sedols(dssusername, dsspassword, sedol, startdate, enddate):
requestUrl = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Authentication/RequestToken"
requestHeaders={
"Prefer":"respond-async",
"Content-Type":"application/json"
}
requestBody={
"Credentials": {
"Username": dssusername,
"Password": dsspassword
}
}
authenticationResp = requests.post(requestUrl, json=requestBody,headers=requestHeaders)
if authenticationResp.status_code == 200 :
jsonResponse = json.loads(authenticationResp.text.encode('ascii', 'ignore'))
token = jsonResponse["value"]
else:
print("Error with status code:",authenticationResp.status_code,"\n Text:",json.dumps(json.loads(authenticationResp.text),indent=4))
return None
requestUrl='https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractWithNotes';
requestHeaders={
"Prefer":"respond-async",
"Content-Type":"application/json",
"Authorization": "token " + token
}
requestBody={
"ExtractionRequest": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.HistoricalReferenceExtractionRequest",
"ContentFieldNames": [
"SEDOL","Change Date"
],
"IdentifierList": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
"InstrumentIdentifiers": [
{ "Identifier": sedol, "IdentifierType": "Sedol" }
],
"ValidationOptions": {"AllowHistoricalInstruments": True}
},
"Condition": {
"ReportDateRangeType": "Range",
"QueryStartDate": startdate,
"QueryEndDate": enddate
}
}
}
extractionResp = requests.post(requestUrl, json=requestBody,headers=requestHeaders)
requestStatus = extractionResp.status_code
print("Received status code " + str(requestStatus))
requestUrl=None
if requestStatus == 202 :
requestUrl = extractionResp.headers["location"]
while (requestStatus == 202):
print ('Received status code 202, waits 10 seconds, then poll again until the status is not 202')
time.sleep(10)
extractionResp = requests.get(requestUrl,headers=requestHeaders)
requestStatus= extractionResp.status_code
if requestStatus == 200 :
extractionRespJson = json.loads(extractionResp.text.encode('ascii', 'ignore'))
return extractionRespJson
else:
print("Error with status code:",extractionResp.status_code,"\n Text:",json.dumps(json.loads(extractionResp.text),indent=4))
return NoneThis method can be used like this:
response = get_new_sedols("dss user","dss password","B7T7721","2022-05-01","2022-09-01")
if response != None:
df = pd.DataFrame(response["Contents"])
new_sedol = df.dropna().sort_values(by='Change Date',ascending=False).iloc[0]["SEDOL"]The output is:
However, it may take a few minutes to extract data.
0 -
Wow! Thanks again Jira!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 中文论坛