question

Upvotes
Accepted
64 2 3 5

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?




dsws-apisedol
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
52.7k 135 44 63

@bob.kim

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"
        },
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.

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!

Upvotes
52.7k 135 44 63

@bob.kim

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.

1663124528169.png

1663124663667.png


1663124528169.png (24.8 KiB)
1663124663667.png (45.5 KiB)
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.

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!

Upvotes
52.7k 135 44 63

@bob.kim

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 None

This 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:

1663224788905.png

However, it may take a few minutes to extract data.



1663224788905.png (47.5 KiB)
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.

Wow! Thanks again Jira!