/Extractions/InstrumentListImportFromBytes Information

Refinitiv customer support recommended me to use /Extractions/InstrumentListImportFromBytes. I cannot find much information in the REST API Reference tree or in the Q&A Forum.

It would be great if you could please provide me with information about what the API does and examples for the input and output.

These are the steps I am trying to follow in order to extract EOD pricing data using an Underling RIC for Futures and Options:

  1. Use DSS GUI to search for Futures and Options using Underlying RIC
  2. Create a CSV or XML file
  3. Refer to the REST API Reference Tree, there is the /Extractions/InstrumentListImportFromBytes endpoint which can import an instrument list from an XML or CSV file.


Best Answer

  • Gurpreet
    Answer ✓

    Hello @ellen.drexler,

    You can read the brief description of this endpoint in the REST API help. To use it, do the following steps:

    1. Read the CSV file into a string

    2. Base64 encode the string bytes

    3. Post this to the DSS

    Here is the sample file in the format (IdentifierType, Identifier):

    RIC,IBM
    RIC,GE
    RIC,TD
    RIC,T
    RIC,SPX
    RIC,PSA.TO
    RIC,MSFT.O

    and the code required to upload it to the server:

    url = 'https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/InstrumentListImportFromBytes';

    with open(fileName, 'r') as f:
    fstr = f.read()
    # convert string to Base64 encoded bytes
    b64str = base64.b64encode(fstr.encode()).decode()

    pBody = {
    'FileBytes': b64str,
    'Settings': {
    'ImportCreatedUserInstrumentsIntoList': True,
    'PredefinedAction': 'Add',
    'AllowDuplicateInstruments': True,
    'PredefinedName': 'ImportedFromAPI',
    'ImportUserInstruments': True
    },
    'FileName': fileName
    }

    resp = requests.post(url, data = json.dumps(pBody), headers = hdrs)

Answers

  • Thank you very much for the answer @Gurpreet.

    Could you please provide me with more information how this step ties into my goal to extract EOD pricing data using an Underling RIC e.g. 'AAL.O' for Futures and Options?

    Using the API 'https://selectapi.datascope.refinitiv.com/RestApi/v1/Search/FuturesAndOptionsSearch' I search using

    requestBody = json.dumps({

    "SearchRequest": {

    "IdentifierType": "Ric",

    "PreferredIdentifierType": "UnderlyingRIC",

    "UnderlyingRic": "AAL.O"

    } })

    This returns:

    {'Identifier': 'AAL.O', 'IdentifierType': 'UnderlyingRIC', 'Source': 'OPQ', 'Key': 'VjF8MHgwMDEwMGIwMDJlMzYwZTE2fDB4MDAxMDBiMDAyZTM1OWE2OXxPUFF8RFZRVXxERVJWfE9QVHxEfHxBQUxGMjEyNDAyMDAwLlV8NzE0MQ', 'Description': 'AAL Jun4 20.0 C', 'InstrumentType': 'DerivativeQuote', 'Status': 'Valid', 'ExchangeCode': 'OPQ', 'CurrencyCode': 'USD', 'FuturesAndOptionsType': 'Options', 'PutCallCode': 'Call', 'ExpirationDate': '2024-06-21T00:00:00.000Z', 'StrikePrice': 20, 'AssetStatus': 'Active'},….. ]

    Should I convert this into a csv/xml and then use InstrumentListImportFromBytes?

    It would be great if you could please help me understand how this will help in my goal to extract eod pricing data for the Underlying RIC "AAL.O".

  • Thank you very much for the answer @Gurpreet.

    Could you please provide me with more information how this step ties into my goal to extract EOD pricing data using an Underling RIC e.g. 'AAL.O' for Futures and Options?

  • Using the API 'https://selectapi.datascope.refinitiv.com/RestApi/v1/Search/FuturesAndOptionsSearch' I search using

    requestBody = json.dumps({

    "SearchRequest": {

    "IdentifierType": "Ric",

    "PreferredIdentifierType": "UnderlyingRIC",

    "UnderlyingRic": "AAL.O"

    } })

    This returns:

    {'Identifier': 'AAL.O', 'IdentifierType': 'UnderlyingRIC', 'Source': 'OPQ', 'Key': 'VjF8MHgwMDEwMGIwMDJlMzYwZTE2fDB4MDAxMDBiMDAyZTM1OWE2OXxPUFF8RFZRVXxERVJWfE9QVHxEfHxBQUxGMjEyNDAyMDAwLlV8NzE0MQ', 'Description': 'AAL Jun4 20.0 C', 'InstrumentType': 'DerivativeQuote', 'Status': 'Valid', 'ExchangeCode': 'OPQ', 'CurrencyCode': 'USD', 'FuturesAndOptionsType': 'Options', 'PutCallCode': 'Call', 'ExpirationDate': '2024-06-21T00:00:00.000Z', 'StrikePrice': 20, 'AssetStatus': 'Active'},….. ]

    Should I convert this into a csv/xml and then use InstrumentListImportFromBytes?

    It would be great if you could please help me understand how this will help in my goal to extract eod pricing data for the Underlying RIC "AAL.O".

  • @ellen.drexler,

    For getting the EOD data, you don't need to create an instrument list. This can be performed using on-demand extraction as well.

    The two steps needed to do so are:

    1. Search for your Future/Options and get a list. You already show an example of this.

    2. Use the search results to create an End of Day on-demand extraction. The sample JSON for this would look like -

    {
    "ExtractionRequest": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.EndOfDayPricingExtractionRequest",
    "ContentFieldNames": [
    "RIC",
    "Security Description",
    "Ticker",
    "Trading Status",
    "Trading Symbol",
    "Underlying RIC",
    ...<<Other fields of interest to you>>>
    ],
    "IdentifierList": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
    "InstrumentIdentifiers": [{
    "Identifier": "AAPL",
    "IdentifierType": "Ticker"
    },
    {
    "Identifier": "IBM.N",
    "IdentifierType": "Ric"
    },
    ...<<All instruments in the search response results>>>
    ]
    },
    "Condition": null
    }
    }

    and POST this JSON payload to https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw.

    You can also see the postman collection in the downloads tab to see a sample EOD extraction use.

  • Hi @Gurpreet ,


    Thank you very much for the above. I understand well how to extract EOD Pricing data for an RIC. However, I am looking how to extract EOD Pricing data given an Underlying RIC.

    Example: Extract eod pricing data for the Underlying RIC "AAL.O".

  • Hi @Gurpreet ,


    Thank you very much for the above. I understand well how to extract EOD Pricing data for an RIC. However, I am looking how to extract EOD Pricing data given an Underlying RIC.

    Example: Extract eod pricing data for the Underlying RIC "AAL.O".

  • @Gurpreet It would be great if you could please help answer the query for an Underlying RIC. Thank you very much.
  • Do you mean futures and options RICs for the AAL.O underlying RIC?

    1714382645415.png

  • Hi
    @Jirapongse ,


    Thank you very much for your response.

    Yes, exactly. I would like to do the above via rest API. Do you know how I could achieve that for Underlying RIC?

  • @ellen.drexler

    You can use the futures and options search. Please refer to the REST API Tutorial 13: Search for a Future or Option tutorial. The request message should look like this:

    {
        "SearchRequest": {        
            "PreferredIdentifierType": "Ric",
            "UnderlyingRic": "AAL.O",
            "AssetStatus":"Active"
        }
    }

    The response looks like this:

    1714383541873.png

    The response will contain the results and the @odata.nextlink.

            {
               "Identifier": "AALE102400900.U",
               "IdentifierType": "Ric",
               "Source": "OPQ",
               "Key": "VjF8MHgwMDEwMGIwMDNiODdkNmRifDB4MDAxMDBiMDAzYjg3NmM1ZXxPUFF8RFZRVXxERVJWfE9QVHxEfHxBQUxFMTAyNDAwOTAwLlV8NzE0MQ",
               "Description": "AAL 2My4 9.0 C",
               "InstrumentType": "DerivativeQuote",
               "Status": "Valid",
               "ExchangeCode": "OPQ",
               "CurrencyCode": "USD",
               "FuturesAndOptionsType": "Options",
               "PutCallCode": "Call",
               "ExpirationDate": "2024-05-10T00:00:00.000Z",
               "StrikePrice": 9,
               "AssetStatus": "Active"
           }
       ],
        "@odata.nextlink": "https://selectapi.datascope.refinitiv.com/RestApi/v1/Search/FuturesAndOptionsSearch?$skiptoken='MjUw'&quot;}

    The @odata.nextlink can be used to retrieve the next page. For more information, please refer to this discussion.

    Then, you can use RICs in the Identifier fields with the EndOfDayPricingExtractionRequest.

  • Hi
    @Jirapongse,

    Thank you very much. I will try this and get back to you.

  • @Jirapongse Thank you very much, this was exactly what I was looking for. Do you have any further documentation/info regarding how to use @odata.nextlink?

  • @Jirapongse E.g. what do we need to put in the request body ect? Thank you very much.
  • @ellen.drexler

    For the odata.nextlink, please refer to the DSS help page.

    Regarding the futures and options search, please test the query on the DSS REST Web UI.

    1714386518058.png

    1714386558559.png

    Then, values on the Web GUI can be used on the REST API.

    You can check the API Reference Tree for the valid parameters of the futures and options search endpoint.

  • Hi @Jirapongse,

    Thank you for the above. I have already implemented the Futures and Options Search, however when I do a GET call for the "@odata.nextlink" "https://selectapi.datascope.refinitiv.com/RestApi/v1/Search/FuturesAndOptionsSearch?$skiptoken='MjUw'", I keep getting 404.

    Do you have an idea why that might be?

  • Hi @ellen.drexler,

    The @odata.nextlink is the field that is included in your Future search JSON response message. This field is only included when the data is large and needs to be paged.

  • Thank you @Gurpreet @Jirapongse,

    The @odata.nextlink is included, however when I do a get call, I keep getting 404. Does this mean there is no data?

  • Are you trying to invoke the URL included in the @odata.nextlink field? This should not result in the 404 error. Please show your complete request JSON message.

  • What a fantastic idea! I have a strong affinity for cranberries, and this dish appears incredibly delectable!

    Delta Executor

    Dooflix

    Filmplus