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 !
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.
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?
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 !