question

Upvotes
Accepted
5 0 1 1

DSWS C# API : how to use the LatestDate function in a DSDataRequest

Hello,

Following the question asked in this thread : https://community.developers.refinitiv.com/questions/45289/dsws-net-api-get-latest-value-of-a-time-series.html, could I get a sample explaining how to use the LatestDate function in a DSDataRequest ?

var request = new DSDataRequest()
{
Instrument = new DSInstrument(isin),
DataTypes = new DSDataTypes(dataTypes),
//Date = new DSTimeSeriesDate(dsDate, dsDate, DSDateFrequency.Daily)
Date = ????
};

I checked the API documentation but it won't help (http://product.datastream.com/DswsClient/Docs/soapapihelp/EnumDetails.html#DSDateNames)

Thank you for your help

datastream-apidsws-api
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
38.1k 71 35 53

@ammeggs

Sorry for the confusion.

I used the example code from here. I think it generates the DataStream classes from the WSDL file.

If you use the library from http://product.datastream.com/DswsClient/Docs/Downloads.aspx, the code should look like this:

var request = new DSDataRequest()
{
    Instrument = new DSInstrument("VOD"),
    DataTypes = new DSDataTypes("PL", "PH"),
    Date = new DSTimeSeriesDate(DSDateType.Literal(DSDateLiterals.BaseDate), DSDateType.Literal(DSDateLiterals.LatestDate), DSDateFrequency.Daily)
};


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.

Hello,

Could you give me the C# code to retreive the Latest Value ?

i.e. the equivalent of the following Excel formula :

=DSGRID("FR0013154002","SOTDDP018","Latest Value")

Thank you

You can try with the LastestDate.

            var DataRequest = new DSDataRequest()
            {
                Instrument = new DSInstrument("FR0013154002"),
                DataTypes = new DSDataTypes("SOTDDP018"),


                Date = new DSSnapshotDate(DSDateType.Literal(DSDateLiterals.LatestDate))
            };

Hello,

I tried that but the C# return no value, while the Excel formula returns 9.3 on the provided example.

Show more comments
Upvotes
38.1k 71 35 53

@ammeggs

It should be used like this:

DataRequest = new DSDataRequest()
{
    Instrument = new DSInstrument() { Value = "VOD" },
    DataTypes = new[] { new DSDataType() { Value = "PL" } },
   
    Date = new DSDate()
    {
        Kind = DSDateKind.TimeSeries,
        Start = DSDateNames.BDATE.ToString(),
        End = DSDateNames.LATESTDATE.ToString(),
        Frequency = DSDateFrequencyNames.D.ToString()
    }
}


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
5 0 1 1

Hello,

Thank you for your reply.
I tried to use your sample code but I get the following compilation errors in Visual Studio :

'DSDate' is inaccessible due to its protection level
'DSDateKind' is inaccessible due to its protection level
DSDateNames' is inaccessible due to its protection level
'DSDateFrequencyNames' is inaccessible due to its protection level

When I navigate to the implementation of theses classes (DSWS API metadata) I see that their protection level is set to internal

I'm using the 1.1.1.0 version of the .NET 4.5 API that I downloaded here : http://product.datastream.com/DswsClient/Docs/Downloads.aspx (release date 24 Jul 2020)

Am I doing something wrong ?






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
5 0 1 1

Works like a charm, thank you !

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.

Click below to post an Idea Post Idea