question

Upvotes
Accepted
21 7 6 11

HistoricalCriteriaSearch how to limit result from the request

Hi,

I have read the documentation but still looking for answers.

I need to limit the result, by example for below POST request it takes 439680 ms to a size of 9.86 MB.


POST /RestApi/v1/Search/HistoricalCriteriaSearch HTTP/1.1
Host: select.datascopeapi.extranet.reuters.biz
Content-Type: application/json
Authorization: Basic OTAxODEwMDpMYWgzNjcwIWY4RDU=
cache-control: no-cache
Postman-Token: 0532c3cc-e48d-4244-a8bd-f033b4ced528
{
"Request": {
"RicPattern": "SEK",
"Range": {
"Start": "2018-11-20T00:00:00.000Z",
"End": "2018-11-21T00:00:00.000Z" } }}

Results as:

"Identifier": "#####T#SEKAB6SFM"

And a lot more noise.

I wish to specify additional parameters in the request such as: "Status" and "IdentifierType". Or similar in order to narrow the result to less noise.

Also I don't understand what "Start" in "Range" is expected to provide? My above request returns by example:

"FirstDate": "2011-06-10T00:00:00.000Z",
"LastDate": "2018-11-27T00:00:00.000Z",

Even if I specified 2018-11-20 to 2018-11-21?

Kind regards,

Johan

tick-history-rest-apihistoricalrest-api
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.

@johan.lundquist, thank you for your participation in the forum. Is the reply below satisfactory in resolving your query? If yes please click the 'Accept' text beneath the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question. Thanks, AHS

Upvotes
Accepted
13.7k 26 8 12

@johan.lundquist,

Your request

It specifies only 2 criteria:

RicPattern - Return all RIC names that contain the string "SEK".

Range - Return all instruments that were active during that time period.

So your query returns all instruments that were active on 20th November 2018, where the RIC contains "SEK". That will deliver many results, hence the long extraction time you observe.

The returned FirstDate / LastDate are the first / last dates where each instrument was active.

Filtering results

You cannot define:

  • The IdentifierType. But results will only contain "Ric" and "ChainRic", nothing else.
  • The instrument "Status". That said, you will only receive instruments that were active in the range you specified. I believe (not 100% sure, I'm not a data specialist) that the returned Status should always be "Valid".

That said, there is a whole set of criteria you can use to limit results:

RicPattern, BondTypeCodes, ContributorIds, CountryCodes, CurrencyCodes, DomainCodes, ExchangeCodes, FutureMonthCodes, InstrumentTypeCodes, OptionMonthCodes, OptionTypeCodes, CouponRate, StrikePrice, ExpiryDate, MaturityDate.

A few comments on these filters:

  • InstrumentTypeCodes can limit results to specific types, like Forex Cash Options (by setting InstrumentTypeCodes to value 211) for instance.
  • CurencyCodes uses a number for each currency, not a string. You can find the numbers using a GET to endpoint /RestApi/v1/Search/GetHistoricalCurrencies. For SEK the number is 752.
  • ExchangeCodes behaves in a similar way, you can find the numbers using a GET to endpoint /RestApi/v1/Search/GetHistoricalExchanges.

Note on the RicPattern regular expression

As per this thread, historical criteria search currently supports only the following regular expression patterns:

  • Begin with: ^ e.g. ^IBM // Begin with ‘IBM’
  • End with: $ e.g. =RR$ // End with ‘=RR’
  • Contain: string e.g. EUR // Contain ‘EUR’

You can escape special characters using a double slash, i.e. "\\"

Example: If you want to use a "." as a literal dot (and not as "any character"), then you need to escape it with , like in "\\.N$" to select any RIC that ends with ".N".

Example query

Retrieve Energy Market Statistics instruments containing "RED" in the RIC, in Danish or Swedish krona:

{
  "Request": {
    "RicPattern": "RED",
    "BondTypeCodes": null,
    "ContributorIds": null,
    "CountryCodes": null,
    "CurrencyCodes": [ "208", "752" ],
    "DomainCodes": null,
    "ExchangeCodes": null,
    "FutureMonthCodes": null,
    "InstrumentTypeCodes": [ "133" ],
    "OptionMonthCodes": null,
    "OptionTypeCodes": null,
    "CouponRate": null,
    "StrikePrice": null,
    "ExpiryDate": null,
    "MaturityDate": null,
    "Range": {
      "Start": "2018-11-20T00:00:00.000Z",
      "End": "2018-11-21T00:00:00.000Z"
    }
  }
}

For more information

The TRTH REST API Tutorial 14 and the REST API Reference tree provide information you might find useful.

Hope this helps.

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
21 7 6 11

Thank you Christiaan for the extensive answer,

I will try write a logic using regular expressions and share result in case of success, for my specific use case. Which is big lists of trades with none- to limited static data in first instance. Where we want to avoid develop too much logic towards internal golden source copies.

Kind regards,

Johan

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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.