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
Can you please have a look and correct what seems wrong to you.
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();
}
}
private void DataReceivedCallback(string feed, 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++)
{
//Save the data somewhere
}
}
Dispatcher.CurrentDispatcher.BeginInvoke(new DispatcherOperationCallback(StopFrame), DispatcherPriority.Background, frame);
}
private static void PushFrame()
{
Dispatcher.ExitAllFrames();
frame = new DispatcherFrame();
Dispatcher.PushFrame(frame);
}
private static object StopFrame(object f)
{
((DispatcherFrame)f).Continue = false;