question

Upvotes
Accepted
9 1 3 5

RediLib Market data slow and cacheEvent fires 3 times every time

I am processing market data updates from Redi Api. When CacheEven occurs and I get an update, the even fires 3 times. I was wondering why that was. Even snapshot fires 3 times
Also when comparing market data tick time to say Bloomberg, I can see it being 200 to 400 milliseconds late. My Redi+ is connected over the internet. Is that the culprit or should it be faster? How long does API take to get data and serve it to me?

redi-api
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
32.2k 40 11 19

Hi @ichernyavskiy,

Each event should be seen once. So let's see how.

The quick way to ascertain it in VB.NET, is to download and run example Quote Monitor API from here:

https://developers.thomsonreuters.com/transactions/redi-api/docs?content=29945&type=documentation_item

It prints every event onto Immediate window, once. Is this what you observe when you run this code, or you still see the triplicates?

Two things I would check next, if what you observe is consistent:

I think the order, when called, is slightly off in the attached picture code, and possibly, also called multiple times.

Any update to the instrument, not necessarily to the fields you are retrieving, will still constitute an update and result in an update event. For example, sometimes ask will update, but not bid, sometimes, bid, but not ask, sometimes neither of these two.

Finally, to assure yourself that there will still be single event with multiple updating symbols, no duplicates or triplicates, one can do a quick code change on this example, see "AddWatch" on Symbol = "IBM", just add another "AddWatch" right after it, on "GOOG" and observe events in Immediate window only, one per.

  tmpVal = L1Cache.Submit(vTable, vwhere, verr)
  tmpVal = L1Cache.AddWatch(0, Symbol, "", verr)
  tmpVal = L1Cache.AddWatch(0, "GOOG", "", verr)
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
9 1 3 5

Zoya, I am working in VB.Net

I've copied snippets of code and pasted them into an image attached. In first sub, I send subscribe to your API. In second subscribe, I subscribe symbol for price updates. and in event handler I listen for action.

In event fire the portion of code I am showing

code prints 1 initially 3 times and then 5 3 times each time price updates.

fire-3-times.png


fire-3-times.png (65.0 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.

Upvotes
9 1 3 5

Zoya, to answer your last question - yes. I am seeing same behavior of event firing 3 times in sample code as well.

Any ideas on what is causing 200-400 milliseconds in latency when compared to Bloomberg for instance?

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
9 1 3 5

Zoya, your link points to a link to github where there are many different projects.

This link is what I more or less copied and pasted in VB. When I see a price update, I can see in eventhandler string is printed 3 times.

https://github.com/TR-API-Samples/Example.REDI.CSharp.Examples/tree/master/REDIConsoleL1

Is there a way to know which field was updated so I can see if maybe 3 fields caused an event fire?

Here is code from your sample in VB. It prints to console same data 3 times each time a field gets updatedfire-3-times-2.png


fire-3-times-2.png (35.2 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.

Upvotes
9 1 3 5

fire-3-times-a.png (9.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.

Upvotes
32.2k 40 11 19

@ichernyavskiy,

Please run the example:

Quote Monitor - API (Global Equities & Futures).xlsm.

This example is very simple and only watches single instrument. It should also be relevant as you work in VB.NET Please observe Immediate Window for a clear, separated view of the updates.

The example you are looking at appears to be C# Console Monitor example.

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
9 1 3 5

The macro in excel only fires once.

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
9 1 3 5

In excel, you have submit first and then AddWatch.

In my code, I have Addwatch and then submit.

In my code, if I do submit first and then AddWatch, I get an exception

Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at RediLib.ICacheControl.AddWatch(Object vaType, Object vaArg1, Object vaArg2, Object& vaError) at TimeTester1.RediConsole1.QuoteCache.Subscribe()

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.

@ichernyavskiy ,

There are likely multiple ways to achieve triplicates :) Do you watch 3 instruments in total per chance? If so, please test with 2 or 4. Just a guess.

One very easy way that I can think of, in C#, to get triplicates without any other errors, is to reuse the same CacheControl instead of creating a new one for every instrument.

Are you able to run the C# L1 example, "REDIConsoleL1", as is, without any enhancements, do you see any duplication of the events?

Upvotes
32.2k 40 11 19

REDI delivers real-time market data to the user interface and API. Update frequency may vary based on specific use cases.

We suggest reaching out to your account manager for more details.

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
9 1 3 5

Zoya,

In excel code, I switched from subit/addwatch to addwatch/submit.

This created multiple updates fire-multiple-times-excel.png

So now I am wondering what am I doing wrong to get the error when doing submit/addwatch in my code.

Looking at some other examples of your code, I see both ways. When I was writing a test application, I received that error message and swapped.

It is throwing same error 3 times as well.

Error in sub Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at RediLib.ICacheControl.AddWatch(Object vaType, Object vaArg1, Object vaArg2, Object& vaError) at TimeTester1.RediConsole1.QuoteCache.Subscribe() in C:\Users\Spare1\Documents\Visual Studio 2010\Projects\TimeTester1\TimeTester1\REDIFEED.vb:line 97

line 97 is where addwatch is happening.


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
9 1 3 5

Thank you, Zoya, for working on this.
I was looking over my example of "duplicates" and it appears in excel example, it was not a duplicate. Example I highlighted was not exactly same. Vwap tick was slightly different.

I have the simplified example from excel and i have my code. I will comb through it again and will let you know if I see any issues. Most likely the issue is between keyboard and chair here.

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
9 1 3 5

Zoya, I figured out why I was getting 3 event fires. In my code, I added handler of the event but that is not necessary.

Initially, my Redi+ was not enabled for API L1 so I added

AddHandler quoteCacheTest.CacheEvent, AddressOf quoteCacheHandler to see if I can get the data to flow. This was not the issue but the code was left over. Once I removed this portion, it stopped firing 3 times and updates only once.

DeleteWatch still does not work properly.

Say I have 2 symbols in my list, SPY and DIA in that order. When I unsubscribe from SPY, it stops subscribing to DIA, but SPY is still updating. When I unsubscribe from SPY again, it again skips SPY.

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.