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
-
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 -
(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 -
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
- 687 Datastream
- 1.4K DSS
- 622 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 254 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 671 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
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛