question

Upvotes
Accepted
1 1 2 6

Retrieving market data at a snap time

Hi,

I need to save live RIC values at a very specific snap time. I've got a list of RICs on different feeds, I realized (am I right ?) that the best solution is to group these RICs by feed and setup a data request for each feed.

Here is the code I'm using: (repoDico is my RICs/Fields/Feeds Dictionary)

I'm using ThomsonReuters.Desktop.SDK.DataAccess.Realtime

List<string> feeds = repoDico.Values.Select(x => x.source).Distinct().ToList();
            List<string> fields;
            List<string> rics;

            var realtime = services.Realtime;

            for (int i = 0; i < feeds.Count; i++)
            {
                _currentFeed = feeds[i];

                fields = repoDico.Values.Where(x => x.source == _currentFeed).Select(x => x.field).Distinct().ToList();
                rics = repoDico.Values.Where(x => x.source == _currentFeed).Select(x => x.ric).Distinct().ToList();

                realtime.SetupDataRequest()
                            .WithRics(rics)
                            .WithFields(fields)
                            .WithFeed((_currentFeed == "IDN") ? "" : _currentFeed)
                            .OnError(RealTimeDataError)
                            .OnDataReceived(DataReceivedChain)
                            .CreateAndSend();

                PushFrame();
            }

The issue I'm having is that whenever there is a 'bad' RIC, it blocks the process. I need a way that snaps the market data and if there's an error, well then the RIC will have no value. The other feeds need to be snapped at the same time.

Thanks for your help.

eikonrefinitiv-realtimeeikon-app-studiosdk
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.

Would it be possible to share more information please? Basically, I am looking for the following event handlers: DataReceivedChain() and RealTimeDataError().

Also, there are no process blocking events that occur in API, you might need to execute something like: Frame.continue = false on your current DispatcherFrame.

Hi Zhenya,

I posted both methods as you can see below.

can you please help ?

Upvote
Accepted
39.2k 75 11 27

Hi @mohammed.amrani-ext,

Yes, the best thing is to setup a separate request per feed.

From the code snippets you included it seems to me that the problem you experience has nothing to do with invalid RICs. Invalid RICs will not be included in IRealtimeUpdateDictionary object passed to OnDataReceived event handler. In fact they will be completely ignored unless you handle OnStatusReceived event where you can see the status of individual RICs.

It seems to me that the problem is that while you create a new DispatcherFrame for each request, you put them all into the same variable?

For your process you might be better off without pushing DispatcherFrames altogether. Just call Dispatcher.Run once after creating IDataServices.

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.

Hi Alex,

Thanks for you answer, and sorry for my delayed one.

Actually, I'm still having some trouble retrieving these data the way I described (at a very defined snap time). Let me explain my issue with more details. Here is the kind of data i'm trying to snap:

Feed RIC Field

INTTKY AUDAUB6M 2D
INTTKY AUDAUB6M 1MIDN AUD= BID
INTPAR MOYAUDBS 3Y
INTPAR MOYAUDBS 4Y

These are just examples, I've got let's say 1000 lines on 6 different Feeds.
So Yes, I'm trying to make a request for each feed.

And I think my issue comes from the way I'm handling the Dispatcher. So I've got two questions:
- Do I need to make a request AND a suscription ? And what's the difference between both ?
- Can you please correct my code by showing the right manner to handle the Dispatcher in order to retrieve the Data (one value per line) in a very short time (just like using RTGet in Excel).

Many Thanls in advance

public void Flash(Dictionary<string, ReutersFlashObject> repoDico)
{ _flashed = new Dictionary<string, double>(); List<string> feeds; List<string> fields; List<string> rics; var realtime = services.Realtime; feeds = repoDico.Values.Select(x => x.source).Distinct().ToList(); for (int i = 0; i < feeds.Count; i++) { fields = repoDico.Values.Where(x => x.source == feeds[i]).Select(x => x.field).Distinct().ToList(); rics = repoDico.Values.Where(x => x.source == feeds[i]).Select(x => x.ric).Distinct().ToList();
request = realtime.SetupDataRequest()
   .WithRics(rics)
   .WithFields(fields)
   .WithFeed((feeds[i] == "IDN") ? "" : feeds[i])
   .OnError(RealTimeDataError)
   .OnDataReceived(update => DataReceivedCallback(feeds[i], update))
   .OnStatusReceived(StatusReceived)
   .CreateAndSend();

subscription = realtime.SetupDataSubscription() .WithRics(rics) .WithFields(fields) .WithFeed((feeds[i] == "IDN") ? "" : feeds[i]) .OnError(RealTimeDataError) .OnDataUpdated(update => DataReceivedCallback(feeds[i], update)) .OnStatusUpdated(StatusReceived) .CreateAndStart(); PushFrame(); } }
Show more comments
Upvotes
1 1 2 6

Hi Zhenya,

Thanks for your reply. Here are the two methods:

private void DataReceivedChain(IRealtimeUpdateDictionary updates)
        {
            string ric = "", field = "";
            for (int i = 0; i < updates.Keys.Count; i++)
            {
                ric = updates.Keys.ElementAt(i);
                for (int j = 0; j < updates[ric].Keys.Count; j++)
                {
                    field = updates[ric].Keys.ElementAt(j);
                    _flashed.Add(ReutersFlashObject.GetKey(_currentFeed, ric, field), updates[ric][field].Value.ToDouble());
                }
            }
            Logger.Instance.Log("the feed " + _currentFeed + " has been snapped.");
            StopFrame();
        }

        private void RealTimeDataError(RealtimeDataError error)
        {
            Logger.Instance.Log(error.Message, Logger.LogType.Fatal);
            StopFrame();
        }
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.

private static void StopFrame()
        {
            Frame.Continue = false;
        }
private static void PushFrame()
  {
  Frame = new DispatcherFrame();
  Dispatcher.PushFrame(Frame);
  }
Click below to post an Idea Post Idea