DSS Tick History REST API. Get RIC historial price, java

HI,


I'm trying to create a request to get historical price from RIC with java, how to get bid/ask price and filter by date? any idea?


            JSONObject searchJSONObject = new JSONObject()
.put("SearchRequest", new JSONObject()
.put("IdentifierType", "Ric")
//.put("Identifier", "US10YT=RRPS")
.put("Identifier", "JPY=")
.put("InstrumentTypeGroups", new JSONArray()
.put("CollatetizedMortgageObligations")
.put("Equities")
.put("FuturesAndOptions")
.put("GovCorp")
.put("MortgageBackedSecurities")
.put("Money")
.put("Municipals")
.put("Funds"))
.put("PreferredIdentifierType", "Ric")
);


Thanks,


Regards

Best Answer

  • Gurpreet
    Answer ✓

    Hi @jasequeirosa,

    If you are trying to get the historical price of an instrument, I recommend that you look at the Java sample for TickHistory which is available in the downloads section of the Dev Portal - specifically DSSOnDemandTicksRTH sample. There are whole bunch of example snippets which include performing on-demand extraction, to search for a Historical Instrument.

    If you have any specific question, you can ask it here.

Answers

  • Hi!,

    Thanks for your answer,

    I tried this example "DSSOnDemandTicksRTH", but got an error as a response:

            try {
    HttpPost httppost = new HttpPost(urlHost + "/Search/InstrumentSearch");

    httppost.addHeader("content-type", "application/json;odata.metadata=minimal");
    httppost.addHeader("Authorization", "Token " + sessionToken);

    JSONOrderedObject searchJSONObject = (JSONOrderedObject) new JSONOrderedObject()
    .put("ExtractionRequest", new JSONOrderedObject()
    .put("@odata.type", "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryTimeAndSalesExtractionRequest")
    .put("ContentFieldNames", new JSONArray()
    .put("Trade - Price")
    .put("Trade - Volume")
    .put("Trade - Exchange Time"))
    .put("IdentifierList", new JSONOrderedObject()
    .put("@odata.type", "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList")
    .put("InstrumentIdentifiers", new JSONArray()
    .put(new JSONObject()
    .put("Identifier", "438516AC0")
    .put("IdentifierType", "Cusip"))
    .put(new JSONObject()
    .put("Identifier", "CARR.PA")
    .put("IdentifierType", "Ric"))
    .put(new JSONObject()
    .put("Identifier", "INVALID")
    .put("IdentifierType", "Ric")))
    .put("ValidationOptions", JSONObject.NULL)
    .put("UseUserPreferencesForValidationOptions", false))
    .put("Condition", new JSONOrderedObject()
    .put("MessageTimeStampIn", "GmtUtc")
    .put("ApplyCorrectionsAndCancellations", true )
    .put("ReportDateRangeType", "Range")
    .put("QueryStartDate", "2016-09-29T15:15:00.000Z")
    .put("QueryEndDate", "2016-09-29T15:16:00.000Z")
    .put("DisplaySourceRIC", true)));


    System.out.println("Search JSON request content:\n"+ searchJSONObject.toString());
    StringEntity requestBody = new StringEntity(searchJSONObject.toString());

    10:25:19.185 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "{"error":{"message":"Malformed request payload: Syntax error at Line 1, Char 22: expected valid json value {\"ExtractionRequest"}}"

    10:25:19.185 [main] DEBUG org.apache.http.headers - http-outgoing-1 << HTTP/1.1 400 Bad Request



    Any idea?


    Regards

  • @jasequeirosa

    The example uses the "/Extractions/ExtractRaw" endpoint.

    1696928697658.png

    It is better to try the RTH REST Tutorials Postman collection example to verify the endpoint and the request message that can be used to get the required data.

  • Hi,

    Thanks!


    I tried this request in the postman but no get a reponse.


    host:

    https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw
    {
    "ExtractionRequest": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryRawExtractionRequest",
    "IdentifierList": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
    "InstrumentIdentifiers": [{
    "Identifier": "EUR=",
    "IdentifierType": "Ric"
    }],
    "ValidationOptions": null,
    "UseUserPreferencesForValidationOptions": false
    },
    "Condition": {
    "MessageTimeStampIn": "GmtUtc",
    "ReportDateRangeType": "Range",
    "QueryStartDate": "2023-10-09T00:00:00.000Z",
    "QueryEndDate": "2023-10-09T00:01:00.000Z",
    "DisplaySourceRIC": true
    }
    }
    }

    any idea?


    Regards

  • @jasequeirosa

    You may try to change the QueryEndDate to "2023-10-09T05:00:00.000Z".

  • Hi,
    Can you try this request?

    {
    "ExtractionRequest": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryRawExtractionRequest",
    "IdentifierList": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
    "InstrumentIdentifiers": [{
    "Identifier": "EUR=",
    "IdentifierType": "Ric"
    }],
    "UseUserPreferencesForValidationOptions": false
    },
    "Condition": {
    "MessageTimeStampIn": "GmtUtc",
    "ReportDateRangeType": "Range",
    "QueryStartDate": "2023-10-09T00:00:00.000Z",
    "QueryEndDate": "2023-10-09T05:00:00.000Z",
    "DisplaySourceRIC": true
    }
    }
    }


    For me, not works...


    Regards

  • @jasequeirosa

    Please share the HTTP Status code and the HTTP response message or the Postman screenshot that shows the HTTP response message.

  • Hi,

    I attach response message and the Postman screenshot


    2023-10-13-08-54-28-dss-tick-history-rest-api-get.png

    Request

    POST https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw
    202
    30.88 s
    POST /RestApi/v1/Extractions/ExtractRaw HTTP/1.1
    Prefer: respond-async
    Content-Type: application/json
    Authorization: Token _W8yLgY1y2IXAIJIGGjbCx6Oz7x3COId8bJY0qYLHk9l3axi7uy6CAN-KTp3HHbxKTUhhsqHNxigaqrYM-5MV7_7WhUioEEXnMCtdTZ6psznDh3oPHNTYK8oowu_CFPvuZkVh4nSnPHMGpuVUCqvPqMsueM8SQM2lclgRcK_7mTHeNX0-n4KiFWdpB19_JwVl3gVffHQpcl8F16MLpAYpPOy4nWFar3PHRSXxViSqdGslPANOfFBe1zyNo2aiqzxFaAJ-w0Md5CLDdhjueHN2lwFc2uENfJVW4FmNAWUoLXI
    User-Agent: PostmanRuntime/7.33.0
    Accept: */*
    Postman-Token: 97763e92-c854-468e-b5e8-f63c1a0a3d36
    Host: selectapi.datascope.refinitiv.com
    Accept-Encoding: gzip, deflate, br
    Connection: keep-alive
    Content-Length: 689

    {
    "ExtractionRequest": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryRawExtractionRequest",
    "IdentifierList": {
    "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
    "InstrumentIdentifiers": [{
    "Identifier": "EUR=",
    "IdentifierType": "Ric"
    }],
    "UseUserPreferencesForValidationOptions": false
    },
    "Condition": {
    "MessageTimeStampIn": "GmtUtc",
    "ReportDateRangeType": "Range",
    "QueryStartDate": "2023-10-09T00:00:00.000Z",
    "QueryEndDate": "2023-10-09T05:00:00.000Z",
    "DisplaySourceRIC": true
    }
    }
    }

    HTTP/1.1 202 Accepted
    Cache-Control: no-cache
    Pragma: no-cache
    Expires: -1
    Location: https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='0x08a986c834892bf9')
    Server: Microsoft-IIS/10.0
    BeginRequestTime: 06:52:39.0643228
    BeginRequestDate: 2023-10-13
    Status: InProgress
    Progress:
    X-Request-Execution-Correlation-Id: CiD/9035378/AAAAAA.08a986c834792bf9/RA
    X-App-Id: Custom.RestApi
    X-App-Version: 17.3.161.64
    CPUUtilization: 49.96478
    RequestsPerSec: 0
    W3WP-PrivateBytes: 2622080
    Date: Fri, 13 Oct 2023 06:53:08 GMT
    Content-Length: 0


    captura.jpg


    Regards

  • @jasequeirosa

    The 202 Accepted means that the extraction is sill in progress.

    Please refer to the Refinitiv Tick History tutorials regading how to process the 202 Accepted response.