Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Eikon Data APIs /

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

avatar image
Question by maboobacker · Nov 27, 2018 at 09:45 PM · eikoneikon-data-apiworkspacepythonworkspace-data-apirefinitiv-dataplatform-eikon.net

How to use onDataReceived callback function

Hi,

I'm trying out your .Net API (nuget package). I'm wondering how to await the callback onDataReceived function? The DataReceived function never gets hit. It is a sample console app. Below is my code:

public void Launch()
        {
            var realtime = DataServices.Instance.Realtime;
            counter = 0;


            _singleRequest = realtime.Request("GBP=", "BID", DataReceived);


            _singleSubscription = realtime.Subscribe("EUR=", "BID", DataReceived);
        }


        private void DataReceived(SingleFieldValue value)
        {
            Console.WriteLine("{0}:{1}({2}) {3}",
                counter,
                value.Ric,
                value.Field,
                value.RawValue);


            counter += 1;


            if (counter == 5)
            {
                _singleRequest = null;
                _singleSubscription.Stop();
                _singleSubscription = null;
                Console.WriteLine("Stopped");
            }
        }

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

8 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Alex Putkov.1 · Nov 28, 2018 at 09:37 AM

@maboobacker
In addition to comments by @Zhenya Kovalyov make sure that Windows message pump is running on the thread housing Eikon .NET API objects, otherwise the objects will not be able to raise events. In a Winforms or WPF application Windows message pump is automatically started on the GUI thread. In a console application you need to explicitly kick off Windows message pump and make sure it keeps running as long as your application needs to retrieve data from Eikon. For an example download one from this tutorial.
And one other thing. We very strongly recommend you keep all your data retrieval from Eikon on a single thread.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by Zhenya Kovalyov · Nov 28, 2018 at 04:08 AM

@maboobacker could you confirm that Eikon is running please? If yes, there might be some sense to subscribe OnError event as well to see why you are not receiving anything.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Answer by maboobacker · Dec 06, 2018 at 04:37 PM

Thanks for the reply. key is Eikon should be running in the same machine where the application runs which I came to know only after conversing with your technical team.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Answer by olymp · Dec 21, 2018 at 03:37 AM

Eventually any idea how to make it work? I'm not able to retrieve the values still

Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
tt1057 · Jun 24, 2019 at 01:10 PM 0
Share

yes, I have the same problem. And not sure, how to tackle it really. An example application, where Eikon .net Api is in a dll.

avatar image
REFINITIV
Answer by Alex Putkov.1 · Jun 24, 2019 at 07:36 PM

@tt1057, @mariosan28
As explained in the accepted answer on this thread, what you need to do is to ensure that Windows message pump is running on the thread housing Eikon .NET API objects. If you're creating a single threaded GUI application, then you don't need to do anything special. Even if you're creating a dll, as long as that dll will only be used on the GUI thread, you're covered. If however your dll may be called by a non GUI thread, then you do need to manage Windows message pump in your dll. Attached is one way of doing it, which I used to create a dll in one of my projects. The attached module implements EikonConnection class, which deals with Windows message pump. EikonConnection class creates an instance of EikonJobHost class, where you can do your work related to retrieving data from Eikon: initialize an instance of DataServices, manage connection state, create real-time data subscriptions etc. EikonJobHost is created on the thread running Windows message pump, which ensures that Eikon .NET API objects created on the same thread within EikonJobHost are able to raise events.
eikonconnection.zip


eikonconnection.zip (1.4 KiB)
Comment
zoya faberov

People who like this

1 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Answer by tt1057 · Jun 25, 2019 at 03:32 PM

thank you Alex. Could you give me a little example for the EikonJobHost class? And how would I get data out of that class then?

and my VS2017 cannot find the reference to:

IEikonDataServiceStateChangeCallback
and what do you reference to to get:

Application

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Answer by tt1057 · Jun 25, 2019 at 03:35 PM

@Alex Putkov. does Refinitiv offer coding service? So, basically, I send you what I got in c#, and you implement the Eikon SDK in there?
I guess it should only be a few hrs work.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by Alex Putkov.1 · Jun 25, 2019 at 08:02 PM

@tt1057

  • No, we're not offering custom software development services.
  • Application is a member of System.Windows.Forms namespace.
  • IEikonDataServiceStateChangeCallback is a custom interface, which allows the event triggered by changes in Eikon .NET API DataServices connection state to be propagated to your application. Here's the code implementing this interface.
public interface IEikonDataServiceStateChangeCallback
{
   /// <summary>
   /// Defines a callback used to receive Service State message.
   /// </summary>
   /// <param name="state">State string received from Data Service</param>
   void OnStateChanged(string state);
}
  • It makes no sense for me to share with you my full implementation of EikonJobHost class, as this is where the business logic of your data retrieval from Eikon goes. You could for example copy & paste the code from UsageExample.cs module from the example in Real-time data retrieval tutorial. You will just need to modify the output code, as this example is a console application, which uses Console.WriteLine method to provide output. It's possible that some other minor modifications may be required. Here's an excerpt from EikonJobHost class containing the constructor and the event handler for the connection state change event.
public class EikonJobHost 
{
    private readonly IEikonDataServiceStateChangeCallback eikonDataServiceStateChange;
    /// <summary> 
    /// Class constructor of EikonJobHost 
    /// </summary> 
    /// <param name="applicationKey">String of Key value, usually the name of the application</param>
    /// <param name="EikonDataServiceStateChange">Application defined function to handle connection status changes</param>
    public EikonJobHost(string applicationKey, IEikonDataServiceStateChangeCallback EikonDataServiceStateChange)
    {
        this.eikonDataServiceStateChange = EikonDataServiceStateChange;
        DataServices.Instance.Initialize(applicationKey);
        DataServices.Instance.StateChanged += new EventHandler<DataServicesStateChangedEventArgs>(DataServicesInstance_StateChanged);
    }


private void DataServicesInstance_StateChanged(object sender, DataServicesStateChangedEventArgs e)
{
    this.eikonDataServiceStateChange.OnStateChanged(e.State.ToString());
}
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
9 People are following this question.

Related Questions

How to get all investors for a list of stocks, historically with the python API

.Net API Infrastructure Error

.net price api in x64 build

Error using Eikon Data API for TR fields

No data events from RIC XAU= and XAU=ALL

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges