Refinitiv.Data .NET library passes DateTime in incorrect format to interday-summaries endpoint

This is referring to my recent report:

Erratic response for interday history request (start date sometimes not included) - LSEG Developer Community

I got an answer from the Historical Pricing API Support Team:

After investigating the issue, we found that the problem arises because the request you are submitting is using an incorrect date format for start/end parameters – the correct date format is  yyyy-mm-dd ex. 2024-12-03. The API is currently unable to process the data correctly due to this format mismatch.

We are using the Refinitiv.Data .NET library which does the call under the hood. We are passing in a DateTime to Refinitiv.Data.Content.HistoricalPricing.SummariesDefinition.Start(DateTime date) method. Apparently this translates the given DateTime object into an incompatible string representation.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @GoGoGroundhog

    Thank you for reaching out to us.

    I found that the Start and End parameters also accept a string.

    image.png

    Therefore, you can connect the DateTime to a compatible date string representation.

  • GoGoGroundhog
    GoGoGroundhog Contributor

    Yes this is actually already my current workaround. The library should still be changed so that it works as expected when using DateTime.

  • nick.zincone
    nick.zincone admin
    edited March 13

    Hi @GoGoGroundhog

    » We are passing in a DateTime to Refinitiv.Data.Content.HistoricalPricing.SummariesDefinition.Start(DateTime date) method. Apparently this translates the given DateTime object into an incompatible string representation.

    Can you share the code you are using that defines the DateTime and the HistoricalPricing call you are making? For example, I just tried this interday monthly request using the following:

    var start = new DateTime(2024, 1, 1);

    var response = Summaries.Definition("VOD.L").Interval(Summaries.Interval.P1M)
    .Fields("TRDPRC_1", "LOW_1", "HIGH_1")
    .Start(start)
    .GetData();
    image.png
  • GoGoGroundhog
    GoGoGroundhog Contributor
    edited March 14

    Sure,
    rdpRequest.Start(fromDateTime.Value.UtcDateTime.Date)

    where fromDateTime is a (nullable) DateTimeOffset with Offset == Timespan.Zero. Note we are using the Date part only, which obviously is a DateTime with hours, mins, secs etc == 0.
    By the way, you are using "P1M" in your posted example. We were using "P1D".
    Also note that the upstream rest API does not always omit the daily bar at fromDate.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @GoGoGroundhog

    I uses the LSEG Data Libaray for .NET and enable the Trace log.

    Log.Level = NLog.LogLevel.Trace;

    Log.Output = (loginfo, parms) => Console.WriteLine($"Application: {loginfo.Level} - {loginfo.FormattedMessage}"); using ISession session = Sessions.GetSession();
    session.Open();
    var response = Summaries.Definition("VOD.L").Interval(Summaries.Interval.P1D)
    .Fields("DATE", "TRDPRC_1", "MKT_OPEN", "VWAP", "LOW_1", "HIGH_1")
    .Start(new DateTime(2025, 03, 01))
    .End(new DateTime(2025, 03, 03))
    .GetData();

    The log shows that the start and end dates in the request message are correct.

    image.png
  • GoGoGroundhog
    GoGoGroundhog Contributor
    • I cannot confirm this. It is consistently adding 0 time for me. This is from the activated log:
    • 2025-03-14T10:50:53 Debug Refinitiv.Data.Delivery.Request.EndpointDefinition Preparing Endpoint GET request http://localhost:9060/api/rdp/data/historical-pricing/v1/views/interday-summaries/FDXZ2^2?fields=DATE,TRDPRC_1,OPEN_PRC,HIGH_1,LOW_1,ACVOL_UNS&interval=P1D&start=2022-09-16T00:00:00.0000000Z&end=2022-12-15T00:00:00.0000000&count=10000&sessions=normal


    • Method: GET, RequestUri: 'http://localhost:9060/api/rdp/data/historical-pricing/v1/views/interday-summaries/FDXZ2^2?fields=DATE,TRDPRC_1,OPEN_PRC,HIGH_1,LOW_1,ACVOL_UNS&interval=P1D&start=2022-09-16T00:00:00.0000000Z&end=2022-12-15T00:00:00.0000000&count=10000&sessions=normal', Version: 1.1, Content: <null>, Headers:
    • 2025-03-14T10:50:53 Debug Refinitiv.Data.Delivery.Request.EndpointDefinition Preparing Endpoint GET request http://localhost:9060/api/rdp/data/historical-pricing/v1/views/interday-summaries/FDXZ2%255E2?fields=DATE,TRDPRC_1,OPEN_PRC,HIGH_1,LOW_1,ACVOL_UNS&interval=P1D&start=2022-09-16T00:00:00.0000000Z&end=2022-12-15T00:00:00.0000000&count=10000&sessions=normal

    Method: GET, RequestUri: 'http://localhost:9060/api/rdp/data/historical-pricing/v1/views/interday-summaries/FDXZ2%255E2?fields=DATE,TRDPRC_1,OPEN_PRC,HIGH_1,LOW_1,ACVOL_UNS&interval=P1D&start=2022-09-16T00:00:00.0000000Z&end=2022-12-15T00:00:00.0000000&count=10000&sessions=normal', Version: 1.1, Content: <null>, Headers:

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    That is not the full code.

    I can't run it.

    It should be like this:

    session.Open();

    var response = Summaries.Definition("VOD.L").Interval(Summaries.Interval.P1D)

    .Fields("DATE", "TRDPRC_1", "MKT_OPEN", "VWAP", "LOW_1", "HIGH_1")

    .Start(new DateTime(2025, 03, 01))

    .End(new DateTime(2025, 03, 03))

    .GetData();
  • GoGoGroundhog
    GoGoGroundhog Contributor
    edited March 14
    var rdpRequest = Summaries.Definition(ric)
    .Interval(request.BarInterval.Value)
    .Count(requestCount)
    .Sessions(ConvertSessions());
    if (request.Fields?.Any() == true)
    rdpRequest = rdpRequest.Fields(request.Fields);
    if (request.FromDateTime.HasValue)
    rdpRequest = rdpRequest.Start(request.FromDateTime.Value.UtcDateTime);
    var maxDate = DateTime.UtcNow.Date.AddMonths(1);
    if (request.ToDateTime.HasValue && request.ToDateTime.Value.UtcDateTime.Date < maxDate)
    rdpRequest = rdpRequest.End(request.ToDateTime.Value.UtcDateTime);
    IDataSetResponse response = await rdpRequest.GetDataAsync();
  • Jirapongse
    Jirapongse ✭✭✭✭✭
    edited March 17

    @GoGoGroundhog

    I assume that you are using the old version of RD Library.

    I tested with 1.0.0-beta1 and found that it sends this request.

    Application: Trace - Sending HTTP request:
    "Method: GET, RequestUri: 'http://localhost:9001/api/rdp//data/historical-pricing/v1/views/interday-summaries/FDXZ2^2?fields=DATE%2CTRDPRC_1%2COPEN_PRC%2CHIGH_1%2CLOW_1%2CACVOL_UNS&interval=P1D&start=2022-09-16T00%3A00%3A00.0000000Z&end=2022-12-15T00%3A00%3A00.0000000Z&count=10000&sessions=normal', Version: 1.1, Content: <null>, Headers:

    However, if I used 1.0.0-beta5, the request is:

    Application: Debug - Preparing Endpoint GET request http://localhost:9001/api/rdp/data/historical-pricing/v1/views/interday-summaries/FDXZ2^2?fields=DATE%2CTRDPRC_1%2COPEN_PRC%2CHIGH_1%2CLOW_1%2CACVOL_UNS&interval=P1D&start=2022-09-16&end=2022-12-15&count=10000&sessions=normal
    Application: Trace - Sending HTTP request:

    Please verify the version of the RD Library.

    You may need to upgrade the application to use the LSEG Data Library fo .NET instead.

    image.png
  • GoGoGroundhog
    GoGoGroundhog Contributor

    And what does this mean?
    "You may need to upgrade the application to use the LSEG Data Library fo Python instead."
    We are not using Python but .NET.

  • Hi @GoGoGroundhog

    Based on your description of 'fromDateTime', I created this little test example that I want you to try:

    DateTimeOffset? fromDateTime = new DateTimeOffset(new DateTime(2022, 9, 16), TimeSpan.Zero);
    var dt = fromDateTime.Value.UtcDateTime.Date;
    Console.WriteLine(dt);
    var test = Summaries.Definition("FDXZ2^2").Interval(Summaries.Interval.P1D)
    .Fields("DATE", "TRDPRC_1", "OPEN_PRC", "HIGH_1", "LOW_1", "ACVOL_UNS")
    .Start(dt)
    .GetData();

    When I look within the logs, I see this:

    'http://localhost:9001/api/rdp/data/historical-pricing/v1/views/interday-summaries/FDXZ2^2?fields=DATE%2CTRDPRC_1%2COPEN_PRC%2CHIGH_1%2CLOW_1%2CACVOL_UNS&interval=P1D&start=2022-09-16'

    I'm using the production version of the library which was released last year as a result of our company requirements to rebrand to LSEG: NuGet Gallery | LSEG.Data 2.0.0

    Ideally, you should upgrade to the latest. In terms of changes, they are minimal. You can find details within the GitHub example package: LSEG-API-Samples/Example.DataLibrary.DotNet: Example projects demonstrating access to the Refinitiv Data Platform using the Refinitiv Data Library for .NET.

    Refer to the bottom of the Readme (Migration).

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Sorry. I meant LSEG Data Library for .NET.

    I have edited the response.

  • GoGoGroundhog
    GoGoGroundhog Contributor

    2025-03-17T07:54:51 Trace Refinitiv.Data.Core.DesktopSessionCore Sending HTTP request:
    Method: GET, RequestUri: 'http://localhost:9000/api/rdp/data/historical-pricing/v1/views/interday-summaries/FDXZ2^2?fields=DATE,TRDPRC_1,OPEN_PRC,HIGH_1,LOW_1,ACVOL_UNS&interval=P1D&start=2022-09-16', Version: 1.1, Content: <null>, Headers:

  • GoGoGroundhog
    GoGoGroundhog Contributor
    edited March 18

    Ok, with a bit of experimentation I can reproduce this now with this minimal repro:

    				var test = Summaries.Definition("FDXZ2^2")
    .Interval(Summaries.Interval.P1D)
    .Fields("TRDPRC_1", "LOW_1", "HIGH_1")
    .Start(new DateTime(2022, 9, 16));
    Debug.WriteLine(test.Properties); // ***

    var testResponse = test.GetData();

    Debug.WriteLine(test.Properties);

    When commenting out the line marked ***, it will work as expected.