question

Upvotes
Accepted
48 2 3 10

Opening a second stream with the same instrument but a different interval results in no data updates

If a stream is opened with a specific instrument and interval (AAPL.O and Daily) and then a second stream is opened with the same instrument and a different interval (AAPL.O and 1M) the second stream does not receive updates. It also happens whether the first stream is closed or left open. Code below...

    static void Main()
    {
        try
        {
            ISession session = DesktopSession.Definition().AppKey("xxxxxxxxxxxxxxxxxxx")
                .GetSession().OnState((state, msg, s) => Console.WriteLine($"{DateTime.Now}: State: {state}. {msg}"))
                .OnEvent((eventCode, msg, s) => Console.WriteLine($"{DateTime.Now}: Event: {eventCode}. {msg}"));
            session.Open();

            // Open a stream with an interval of 1 day
            var stream1 = Summaries
                .Definition("AAPL.O")
                .Fields("OPEN_PRC", "HIGH_1", "LOW_1", "TRDPRC_1", "ACVOL_UNS")
                .Count(10)
                .Interval(Summaries.Interval.P1D)
                .GetStream(session);

            bool waitingForFirstUpdate = true;
            stream1
                .OnInsert((data, t) => { Console.WriteLine("AAPL.O Daily OnInsert"); })
                .OnUpdate((data, t) => 
                { 
                    Console.WriteLine("AAPL.O Daily OnUpdate");
                    waitingForFirstUpdate = false;
                })
                .OnError((data, t) => { Console.WriteLine("AAPL.O Daily OnError"); })
                .Open();

            while (waitingForFirstUpdate)
            {
                // As soon as we get the first update we can continue
            }

            Console.WriteLine("Closing AAPL.O D");
            stream1.Close();

            var stream2 = Summaries
                .Definition("AAPL.O")
                .Fields("OPEN_PRC", "HIGH_1", "LOW_1", "TRDPRC_1", "ACVOL_UNS")
                .Count(10)
                .Interval(Summaries.Interval.PT1M)
                .GetStream(session);

            stream2
                .OnInsert((data, t) => { Console.WriteLine("AAPL.O 1M OnInsert"); })
                .OnUpdate((data, t) => { Console.WriteLine("AAPL.O 1M OnUpdate"); })
                .OnError((data, t) => { Console.WriteLine("AAPL.O 1M OnError"); })
                .Open();

            Console.ReadLine();
        }
        catch (Exception e)
        {
            Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************");
        }
    }

The output looks like this...

1/26/2024 10:48:22: State: Pending. DesktopSession is Pending
1/26/2024 10:48:24: Event: SessionAuthenticationSuccess. {
  "Contents": "Desktop Session Successfully Authenticated"
}
1/26/2024 10:48:24: State: Opened. DesktopSession is Opened
1/26/2024 10:48:24: Event: StreamConnected. {
  "Contents": "Successfully connected into the WebSocket server: localhost:9000/api/rdp/streaming/pricing/v1/WebSocket"
}
1/26/2024 10:48:24: Event: StreamAuthenticationSuccess. {
  "Contents": "Successfully logged into streaming server localhost:9000/api/rdp/streaming/pricing/v1/WebSocket"
}
AAPL.O Daily OnInsert
AAPL.O Daily OnInsert
AAPL.O Daily OnUpdate
Closing AAPL.O D
AAPL.O Daily OnUpdate
AAPL.O Daily OnUpdate
AAPL.O 1M OnInsert

Even if the original stream is left open the OnUpdate handler for the second stream is never called. This is with version 1.0.3 of the Data Library. It may be related to https://community.developers.refinitiv.com/questions/111730/incorrect-prices-in-update-events-after-closing-an.html as the setup is similar but the behavior is now different.

#producthistoricalrefinitiv-data-platform-librariesstreaming-data
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
Accepted
202 4 1 3

Hello @cory.schmidt.1


I discovered the issue.

The problem was that when creating a stream with an interday interval for a given instrument, metadata would be loaded for those properties and interday rules were generated based on it. When the same instrument would need a second stream with an intraday interval, it would detect that it already has a metadata loaded and would skip loading a second one. This means that for intraday, the same interday rules would be used leading to NO updates published for the intraday stream.

The fix was to modify the dictionary holding our instrument metadata objects to take into account the record type (which differs between intraday and interday intervals).

I will have to review with Nick this approach and if everything is green, I will notify you as soon as we have published a new version.

Below is a snapshot of running the example of this post after the fix:

1706531642588.png


Thank you for your patience,

Cristian


1706531642588.png (70.1 KiB)
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.

Great news. Thanks!
With version 1.0.4 we are able to receive updates on the second 1-minute stream. Thanks!
Upvotes
202 4 1 3
Hello @cory.schmidt.1

I tried investigating using EUR= instead of APPL.O as an instrument and I encountered no issues with inserting and updating for the example given above. EUR= and APPL.O have different blending rules, where for EUR= I wasn't able to spot any issues so far.

This issue might be related with the one described in question 111730. If the incoming message from the queue is processed by incomplete/incorrect rules, it might lead to the intraday summarizer ignoring some resulting records, meaning updates are skipped (or in other cases the opposite might happen, where records are generated when they shouldn't be and then we get extra updates).

I will try to use APPL.O later today when the market is open and see what results I get.

Thank you for your patience,

Cristian

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
202 4 1 3

Hello @cory.schmidt.1

I've tested retrieving data using AAPL.O, but with a small modification. I only opened the one minute stream and it seems there are updates coming in. Only when I open the daily and then close it before I open the second stream with the one minute period, the issue explained above happens.

This might not be related to 111730 after all.

Continuing investigation into the issue...

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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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