question

Upvotes
Accepted
3 0 0 2

Is there a way to put a loop using the RHistoryAPI file example?

I am trying to do a series of data retrieval using RHistoryAPI. When I put it in a loop with for...next it retrieves only the last instance and all the others are not taken into consideration.

eikoneikon-com-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.

Upvotes
Accepted
39.4k 77 11 27

Hi @tibor.palugyai,

The behavior you describe is expected. In your loop you rapidly change the properties of the same instance of RHistoryQuery class without giving the object time to retrieve the data.
To retrieve multiple timeseries you may not need multiple queries. If your queries are identical except for the RIC, then you can pass semicolon separated list of RICs (e.g. "TRI.N;IBM.N;AAPL.O") to InstrumentIdList property of RHistoryQuery object. This way you won't need any loops, all the timeseries will be retrieved in a single request.
If you need to retrieve timeseries for different fields, time intervals etc., then you either need to create an artificial loop between the requesting procedure and OnUpdate event callback, or you need to use multiple instances of RHistoryQuery class and put them in a collection where each RHistoryQuery object will be stored until it retrieves the data. Let me know if you need an example for either of the techniques.

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
3 0 0 2

Hi Alex,

Thanks for the answer. As I use identical queries the semicolon solution will work fine. Is there any limitation in terms ofnumber of RICs in the semicolon separated list?

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.

There's no formal limit, which of course does not mean it's unlimited. There are always practical limits, we just cannot reliably quantify where they are, as there are too many interrelated variables in play. As you increase the number of instruments you will first see degradation of response time. And if you increase it even further, at some point you'll start seeing unexpected behavior. To give you a rough idea, dozens of RICs are definitely safe to use, low hundreds are probably OK, thousands are likely too many. But is also depends on the interval, the number of data points etc. etc.

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.