question

Upvotes
Accepted
45 7 11 10

.NET timeseries : different results for same request

Hello,

I am using the TimeSeries object from the .NET library.

Everything is working but I observed something that I would like to understand. When I do the same request recursively, (same RIC, same View and same date interval) the API return different results.

Here is an example :

_request = TimeSerieItem.SetupDataRequest("BBEURENE1Y=")
                .WithView("PAR_YLD")
                .WithAllFields()
                .From(new DateTime(2016,1,1))
                .To(new DateTime(2017,1,1))
                .WithInterval(CommonInterval.Daily)
                .OnDataReceived(DataReceivedCallback)
                .CreateAndSend();

This request will return the correct results the first time. If I call it again (during the same run time) with the same param the resulted enumeration will be empty.

I tried to create a new instance of TimeSerieItem for each request like this:

TimeSerieItem = Service.TimeSeries;
TimeSerieItem.ServiceInformationChanged += timeSeries_ServiceInformationChanged;

but it does not change anything.

Could someone explain me the reason of such results ?

Thank you !

eikoneikon-com-apitime-series.net
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

Timeseries data is frequently retrieved in portions aka chunks. New OnDataReceived event is raised each time a new chunk of timeseries data is retrieved. You may have multiple OnDataReceived events raised for a single request and chunk.IsLast property is provided to tell when the data retrieval for a given request is complete. A chunk returned into OnDataReceived event handler may contain no records. This most commonly happens for the last chunk retrieved for the request. In other words it's common when for a given request several OnDataReceived events are raised with chunks of timeseries delivered in each instance of the event and no timeseries delivered in the last instance of the event (the last event merely signifying that the data retrieval for the request is complete through chunk.IsLast == true).
The above behavior is normal and expected for any request. See the section titled "Request" in this tutorial. Make sure you check IsLast property in your OnDataReceived event handler. If chunk.IsLast == false you should expect further OnDataReceived events for the same request.
I'm afraid I'm not following the significance of adding recursive call to the Request procedure from within OnDataReceived event handler. Apart from creating an obvious endless loop, you actually may have exponentially multiplying endless loops since each request may result in multiple OnDataReceived events.

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
39.4k 77 11 27

I'm not sure I understand what you mean by "empty enumeration". Are you saying the chunk object returned to DataReceivedCallback contains zero records? This can happen when multiple OnDataReceived events are raised for the same request, which is quite common. Are you collecting records from each chunk returned every time OnDataReceived event is raised and checking IsLast property to determine when all data has been retrieved for the RIC?

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.

Let's suppose that situation :

public void Request(){ 
_request = TimeSerieItem.SetupDataRequest("BBEURENE1Y=") .WithView("PAR_YLD") .WithAllFields() .From(new DateTime(2016,1,1)) .To(new DateTime(2017,1,1)) .WithInterval(CommonInterval.Daily) .OnDataReceived(DataReceivedCallback) .CreateAndSend();
}
private void DataReceivedCallback(DataChunk chunk){ 
// Here I check the data received
// First time request return around 60 records
// Zero records are returned the second time
Request(); }

As you can see parameters are not changed and the callback function is always the same.

Of course this is not a real situation, in my case the constituent's RIC will be updated to retrieve information for all the maturity.

I just wonder why this happens ?

Upvotes
45 7 11 10

Aaah ok I did not understand that the SetupDataRequest method could trigger the callback function more that once... thought I was only the case with the SetupDataSubscription method.

Now if I check the IsLast property of the chunk before requesting again everything is working as expected ! Logic !

Thanks a lot for your help @Alex! It gives me a better understanding !

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.