question

Upvotes
Accepted
5 1 3 6

Access Chunk records in MATLAB

May I ask how to read the the following data in MATLAB?


timeSeriesRequestSetup = timeSeries.SetupDataRequest('ATGOV1YZ=R');

timeSeriesRequestSetup.WithView('DISC_FACTR');

timeSeriesRequestSetup.WithInterval(ThomsonReuters.Desktop.SDK.DataAccess.TimeSeries.CommonInterval.Daily);

timeSeriesRequestSetup.From(System.DateTime(2021,06,30));

timeSeriesRequestSetup.To(System.DateTime(2021,07,30));

timeSeriesRequestSetup.OnDataReceived(@DataReceivedCallback);

timeSeriesRequestSetup.CreateAndSend();


When DataReceivedCallback is trigged, the following line returns an empty structure.

records = chunk.Records.GetEnumerator();

eikoneikon-com-apimatlab
icon clock
10 |1500

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

Upvotes
Accepted
39.2k 75 11 27

@xuewei.zhu

How many OnDataReceived events are raised when you execute your code in Matlab, and what's the value of chunk.IsLast property returned into the event handler? Can you also create an event handler for OnStatusUpdated event of ThomsonReuters.Desktop.SDK.DataAccess.TimeSeries.ITimeSeriesDataRequestSetup interface and see if this event is raised and what info you can get out of it about the status of the request?

icon clock
10 |1500

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

@Alex Putkov.

The OnDataReceived events are raised twice. The first one is empty but the second one is not!

How should I read out the data returned from records.current?

I tried ToBarCode but all properties has no value stored.


It's normal and expected that the OnDataReceived event may be raised several times, and that for some of these events the chunk returned into the event handler may be empty. There's a number of ways to extract the timeseries data from the chunk object. Using ToBarRecord (for a single record) or ToBarRecords (for a collection of records) should work when you retrieve the data that can be summarized into OHLC (open/high/low/close). This includes timeseries for ATGOV1YZ=R when you use .WithView("DISC_FACTR") and .WithInterval(CommonInterval.Daily). In this particular example, since there's only one value per day, only the Close property of IBarData will be populated while Open, High and Low will be empty. There may also be some records where all properties are empty (e.g. for dates that fall on a holiday). For more examples of extracting timeseries data from the chunk object see the tutorial for Timeseries data retrieval using Eikon .NET SDK.

I have tried again using ToBarRecord but all the properties are empty. However, I found this ToTickRecord which has the correct value in it!

empty bar.PNGToTickRecord.PNG

empty-bar.png (22.5 KiB)
totickrecord.png (8.2 KiB)
Show more comments
Upvotes
38.1k 71 35 53

@xuewei.zhu

I can retrieve the data properly with the following code when using Visual Studio.

 request[0]= timeSeries.SetupDataRequest("ATGOV1YZ=R")
    .WithAllFields()
    .WithView("DISC_FACTR")
    .WithInterval(CommonInterval.Daily)
    .From(new DateTime(2021,6, 30))
    .To(new DateTime(2021,7,30))
    .OnDataReceived(OnTSReceived)
    .OnStatusUpdated(OnTSStatus)
    .CreateAndSend();

The OnTSReceived callback was called twice.

On the first call, the value of chunk.IsLast is false and the returned enumerator contains the data from 6/30/2021 to 7/30/2021.

1629088982670.png

On the second call, the value of chunk.IsLast is true and the returned enumerator is empty.

1629089083640.png



1629088982670.png (55.3 KiB)
1629089083640.png (50.6 KiB)
icon clock
10 |1500

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

Yes. I can retrieve data using visual studio as well. But not able to read it in to MATLAB properly.
Click below to post an Idea Post Idea