question

Upvotes
Accepted
7 1 0 4

How can I return date with corresponding value when calling GetData with DSTimeSeriesDate using datastream .net api

How can I return date with corresponding value when calling GetData with DSTimeSeriesDate using datastream .net api

Here is an example

var datatype = "REBE#(X/FTSE100)-100";

var request = new DSDataRequest()

{

Instrument = new DSInstrument(identifier),

DataTypes = new DSDataTypes(datatype),

Date = new DSTimeSeriesDate(DSDateType.Literal("-2Y"), DSDateType.Literal(""), DSDateFrequency.Daily),

};

var response = DSClient.DataService.GetData(request);

double[] values = response[datatype][identifier].GetValue<double[]>();


How can I return collection of objects that gives date and its corresponding value

apidatastream-apidsws-api.netdatastream
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.

Upvote
Accepted
47.2k 109 44 60

@vishal.kak

Dates can be accessed via response.Dates.

            double[] values = response[datatype]["U:IBM"].GetValue<double[]>();


            for (int i = 0;i < values.Length; i++){
                Console.WriteLine("{0} \t {1}", response.Dates[i], values[i]);
            }
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.3k 76 11 27

@vishal.kak

If you were using Datastream Web Service WSDL, as described in DSWS Tutorial - Microsoft Visual Studio, the array of dates is provided by the Dates property of DSDataResponse class. However, you mentioned on this thread, that you're using ThomsonReuters.DswsApi.NET4.5.dll, which I'm not familiar with. I'm afraid before I can give you any advise, I need to understand what ThomsonReuters.DswsApi.NET4.5.dll is. Would you mind sharing where you got it from? I couldn't find any references to it internally or externally.

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.