Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 2

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();

}

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apipricing
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.

Hello @taltonji

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?

If so please can you click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question.

Thanks,

AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

Upvotes
Accepted
39.4k 77 11 27

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();
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
1 0 0 2

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.

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.

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?

Upvotes
1 0 0 2

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.

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
39.4k 77 11 27

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.

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
1 0 0 2

****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();

}

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
39.4k 77 11 27

@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.

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
17.4k 82 39 63

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)
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.