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 /
avatar image
Question by taltonji · Jul 12, 2019 at 09:40 AM · closing prices

Retrieving Closing Prices

I am trying to make a time series request to get the most recent closing price for Apple. I used your sample program. I changed the request from EUR= to AAPL.O. I changed .WithView from BID to CLOSE. I am not getting data back. What am I doing wrong? see code below:

publicvoid Launch()

{

Console.WriteLine("[2] Time series request example");

Console.WriteLine("");

// request = timeSeries.SetupDataRequest("EUR=")

request = timeSeries.SetupDataRequest("AAPL.O")

.WithView("CLOSE")

.WithAllFields()

.WithInterval(CommonInterval.Daily)

.WithNumberOfPoints(10)

.OnDataReceived(DataReceivedCallback)

.CreateAndSend();

}

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.

7 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Alex Putkov. · Jul 12, 2019 at 11:46 AM

The view differentiates between trades, quotes (bid/ask) and other types of market data updates (yields for bonds, implied volatility for options etc. etc.), not between summarization points such as Open, High, Low, Close. Within any view you may have Open, High, Low, Close. E.g. you may have Open for the view BID and Close for the view ASK, and High for the view TRDPRC_1, which represents the trade. If you want close trade price you should use WithView("TRDPRC_1") or even better omit WithView method altogether. For each RIC there's a default view, which is applied if you don't specify the view using WithView. For stocks the default view is TRDPRC_1. The following code will get you the daily summarization of the stock trade price including Open, High, Low and Close.

request = timeSeries.SetupDataRequest("AAPL.O")
.WithAllFields()
.WithInterval(CommonInterval.Daily)
.WithNumberOfPoints(10)
.OnDataReceived(DataReceivedCallback)
.CreateAndSend();
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 taltonji · Jul 18, 2019 at 04:27 PM

So now I can get a closing price for "IBM.N" but this is the only security I can get. When I change the sample ticker to XON.N or anything else I do not get anything. What am I doing wrong? Sam code, different ticker.

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
REFINITIV
Alex Putkov. ♦♦ · Jul 18, 2019 at 05:19 PM 0
Share

It's practically impossible to guess what's wrong with this level of detail. Would you care to elaborate? What changes did you make to the original example? How are you running it? What exactly are the symptoms? Did you notice any patterns?

avatar image
Answer by taltonji · Jul 19, 2019 at 09:20 AM

My program is working on the first security but not on subsequent tries. I have a test screen which prompts for a ticker, calls the api and displays a closing price after I press a button. So I can enter IBM.N and get a price but after this when I enter another ticker such as X.N, I get nothing. From stepping through the code I'm seeing that subsequent request after the first one are not triggering the event below:

privatestaticvoid timeSeries_ServiceInformationChanged(object sender, ServiceInformationChangedEventArgs e)

{

Console.WriteLine("{0}: {1}", e.Information.State, e.Information.Message);

TimeSeriesRequest(Globals.Symbol.Trim());

}

Since this is where the actual request is made, I don't get any more prices after the first request.

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. · Jul 19, 2019 at 10:42 AM

This is an error in the business logic of your application. Move the request from the ServiceInformationChanged event handler to the event handler for user input. ServiceInformationChanged event is raised when the connection state between your application and Eikon changes. It is not expected to be raised when you receive symbol input from a user. See this tutorial for more details about what ServiceInformationChanged event is used for.

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 taltonji · Jul 19, 2019 at 03:31 PM

****I have a small test program. I can enter a security (IBM.N).

I get a quote but I have to press a button twice to get results. The code for the button is below. Calling the API routine twice in the click routine will not retrieve the price. I need to actually press the button twice. I don't understand why. Any ideas?

When I press a button the ****program does the following:

privatevoid txtTest_Click(object sender, EventArgs e)

{

txtPrice.Text = thomsonAPI.GetPrice("Test", txtSymbol.Text.Trim());

}

**************The API routine looks like:

publicstring GetPrice(string application, string ticker)

{

Globals.Symbol = ticker.Trim();

Globals.Callback = false;

InitializeDataServices(application.Trim());


TimeSeriesRequest(Globals.Symbol.Trim());

return Globals.Price;

}

**********The Globals.Price field is set in

privatevoid DataReceivedCallback(DataChunk chunk)

{

foreach (IBarData bar in chunk.Records.ToBarRecords())

{

if (bar.Open.HasValue && bar.High.HasValue && bar.Low.HasValue && bar.Close.HasValue && bar.Timestamp.HasValue)

{

Globals.Price = bar.Close.Value.ToString();

}

}

if (!chunk.IsLast) return;

request = null;

ThomsonAPI.StopMessagePump();

}

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. · Jul 19, 2019 at 04:40 PM

@taltonji
When posting a new question, please always start a new thread. Otherwise your question can be easily missed, especially if you post it on a thread that already has accepted answer. Those threads are not monitored by moderators at all.
The behavior you experienced is the result of a business logic error in your code, which assumes the data is retrieved synchronously when in fact it is retrieved asynchronously. Here's what happens when your code is executed. You send the timeseries request and immediately return Globals.Price, which at this point is either empty or contains a value from the previous request. This value is displayed in txtPrice.Text. Then DataReceivedCallback is raised once the data requested has been retrieved from the platform. The event handler updates the value in Globals.Price and exits. It does not update the value in txtPrice.Text until you click the button again. Correct business logic would be to do away with your GetPrice function, which serves no useful purpose. Instead call TimeSeriesRequest on button click, and assign the value to txtPrice.Text once the data has been retrieved in the DataReceivedCallback event handler. Alternatively in a WPF application you could bind txtPrice.Text property to a variable (for instance Globals.Price in your example), which would update the value of the property each time the value of the variable is updated.

Here's a couple of unrelated remarks on your code.

1. It appears that you initialize data services every time you request data. There's no need for that. Typically you need to initialize data services once when your application starts. And then as long as your application and Eikon are both running and Eikon is connected to Refinitiv hosted Eikon platform you can keep requesting data without re-initializing data services.

2. You appear to start and stop Windows message pump every time you request data from Eikon. There's no need to do that. You only need to start Windows message pump at the start of your application, and stop it only when the application exits. And since this appears to be a GUI application, you don't need to start and stop Windows message pump at all. In a GUI application Windows message pump is started automatically on the GUI thread, and I very strongly recommend that all data retrieval using Eikon .NET API is performed on the GUI 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 nick.zincone.1 · Jul 19, 2019 at 04:42 PM

Hi @taltonji,

If you need to understand/troubleshoot application logic, I would add some additional callback logic to see what other events may be occurring. You are likely not receiving data responses because events are being raised within your OnStatusUpdated() handler.

I would first add logic like this to your SetupDataRequest(), i.e.

Also, you seem to be calling InitializeDataServices() every time you click to get data. I'm not sure why because you should only need to do this once your application starts.


ahs.png (11.3 KiB)
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

last trading price is 0 when market is closed for GILD.OQ

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • 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
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges