question

Upvotes
Accepted
1 1 2 5

Real time last price including extended hours trading

Hi,

I am trying to get the last price for a specific instrument, but I want the price to include prices from extended hours. I have tried two fields: CF_LAST and IRGPRC. The first does not include trades from extended hours, whereas IRGPRC is reset every day, so if no trades have occured today, zero is returned. From excel I have been advised to use the Rhistory function as follows:

=RHistory("AAPL.O","TRDPRC_1.Timestamp;TRDPRC_1.Value;TRDPRC_1.Count","NBROWS:1 ADJUSTED:NO INTERVAL:TAS",,,I7),

since no live data field can give me what I am after, but I have not been able to translate this into a AdxRtHistory query. I have been able to create a historic query using the historic .net api, but I have only been able to do it by requesting data from a specific timestamp and potentially this can be a lot of data. Do you have any suggestions?

Thanks,

Andreas

eikoneikon-data-apieikon-com-apipricing
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.

Upvotes
Accepted
39.2k 75 11 27

My bad. I omitted the filter to include extended hours trade records:

.WithFilter(filter => filter.IncludeOutOfSessionRecords(true))

This should do it.

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.

Upvotes
4.6k 26 7 22

@jeppe which RIC are you trying to query? Extended traded sessions may affect the live RIC differently on different exchanges.

AdxRtHistory only supports inter-day data, so requesting intraday time series will not work, so the only only API that might be of use for you is .NET.

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.

Upvotes
39.2k 75 11 27

Hi Andreas,

You're on the right track with this: "I have been able to create a historic query using the historic .net api, but I have only been able to do it by requesting data from a specific timestamp and potentially this can be a lot of data." When setting up timeseries request use the following methods of ITimeSeriesDataRequestSetup interface:

.WithInterval(CommonInterval.Trades)
.To(DateTime.Now)
.WithNumberOfPoints(1)

This will allow you to retrieve the single latest trade.

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.

Upvotes
1 1 2 5

That does the trick of getting the latest trades. Thank you. Unfortunately, I get some strange behavior. My request looks like this:

request = timeSeries.SetupDataRequest("MSFT.O")
.WithAllFields()
.To(DateTime.Now)
.WithInterval(CommonInterval.Trades)
.WithNumberOfPoints(59)
.OnDataReceived(DataReceivedCallback)
.CreateAndSend();

With this request I get back 59 data points, but they do not include trades from extended trading hours. If I specify 58 number of points, zero data points are returned. If I instead use .To(DateTime.Today), the requested number of points is returned (still missing extended hours), but by adding seconds (.To(DateTime.Today.AddSeconds(12))) I sometimes get zero sometimes the requested number of data points depending on the requested number and the added seconds.

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.

Upvotes
1 1 2 5

It works! Thanks a million!

Do you by any chance have an example console application too? I am having trouble translating the message pump stuff.

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.

Upvotes
39.2k 75 11 27

Hi Andreas,

All the examples in the downloads section on this API are console applications:

https://developers.refinitiv.com/en/api-catalog/eikon/-net-apis-for-use-in-custom-applications/download

Have you seen these? Anything in particular you're struggling with? There are numerous ways to start Windows message pump. The technique used in the above examples is one way, there are several others, e.g. using Application.Run method.

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.

Upvotes
1 1 2 5

I figured out my issues, and those are the examples I have been working on.

Thank you very much for your help.

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.

Click below to post an Idea Post Idea