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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 1 4

Retrieve Futures Contract Names at a point-in-time

Hi there, is there a way to retrieve contract names of a futures product available on a date in the past using Eikon Python API? For example, crude oil on March 1, 2002 there were CLH02,CLJ02,CLK02,....CLZ04... etc on exchanges. Would the API get these names? Need to get these names first and then to check historical info like close prices, first notice date of these contracts, thanks.

pythonfuturesexpired-contract
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.

Upvote
Accepted
31.9k 38 11 19

Hello @zhangjin ,

With Eikon Data API only, for a date in the past, I don't believe you will be able to have the complete solution.

For chain expansion in history, history product, such as Refinitiv Tick History, would work. We have several materials available, for instance, see article How to expand Chain RIC using the Tick History REST API in Python, but the approach described requires Tick History product.

Otherwise, you can expand today and request at a point in time, which will not result in the complete retrieval at point-in time as some constituents would be expected to have changed overtime.

Once you have the chain constituents in time, you can retrieve any information for the list of constituents in that point of time using Eikon Data API. For example:

ek.get_data(df["Instrument"].tolist(),
                  ['TR.CLOSEPRICE','TR.CLOSEPRICE.date'],
                  {'SDate': '20211001','EDate':'20211101'}
                 )

To see what fields are available, Data Item Browser tool (DIB) can be used, see article How to discover available fields for Data Grid service on JET(App Studio HTML5 SDK) API using Eikon Desktop for more info.

I hope that this information helps

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
31.9k 38 11 19

Hello @zhangjin ,

I think the best pure Eikon Data API approach is described in this previous discussion thread:

1. Expand the CRUDE OIL RIC chain as it is now

2. Obtain the historical information on the dates that you require based on the instruments expanded in step 1.

With history product, for example Refinitiv Tick History, you can use Historical Chain Resolution request to expand that chain in the exact point in time, see this previous discussion thread for a discussion of this approach, and you can request close prices and other fields based on the expanded RIC list.

Hope this information helps

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.

Hi Zoya, I still don't have a clue after reading the thread you provided. I don't need to know 'joiners' and 'leavers' or other information.

I want to know what futures contracts are available for trade on exchange given a date, like today or a date in history. Is there a way using a root RIC + a date to fetch these contract names?

Upvotes
3 0 1 4

Hi, My problem is not solved, thanks for asking @raksina.samasiri.

I want to know what futures contracts are available for trade on exchange given a date, like today or a date in history. Is there a way using a root RIC + a date to fetch these contract names? Thanks.

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
31.9k 38 11 19

Hello @zhangjin ,

Sorry your problem is not solved and let me provide some additional information.

For today, I would suggest using Refiniv Data library, please try the following code:

import refinitiv.data as rd
from refinitiv.data.content import historical_pricing
from refinitiv.data.content import pricing

rd.open_session()

cruds = pricing.chain.Definition(name="0#CL:").get_stream()
cruds.open(with_updates=False)
cruds.close()
print(cruds.constituents)

Resulting in constituents:

['CLK2', 'CLM2', 'CLN2', 'CLQ2', 'CLU2', 'CLV2', 'CLX2', 'CLZ2', 'CLF3', 'CLG3', 'CLH3', 'CLJ3', 'CLK3', 'CLM3', 'CLN3', 'CLQ3', 'CLU3', 'CLV3', 'CLX3', 'CLZ3', 'CLF24', 'CLG24', 'CLH24', 'CLJ24', 'CLK24', 'CLM24', 'CLN24', 'CLQ24', 'CLU24', 'CLV24', 'CLX24', 'CLZ24', 'CLF25', 'CLG25', 'CLH25', 'CLJ25', 'CLK25', 'CLM25', 'CLN25', 'CLQ25', 'CLU25', 'CLV25', 'CLX25', 'CLZ25', 'CLF26', 'CLG26', 'CLH26', 'CLJ26', 'CLK26', 'CLM26', 'CLN26', 'CLQ26', 'CLU26', 'CLV26', 'CLX26', 'CLZ26', 'CLF27', 'CLG27', 'CLH27', 'CLJ27', 'CLK27'...

That we can request the info that you require, for example:

non_streaming = rd.content.pricing.Definition(
    cruds.constituents,
    fields=['TRDPRC_1','ASK','BID']
).get_stream(
non_streaming.open(with_updates=False)
non_streaming.get_snapshot()

resulting in:

InstrumentBIDTRDPRC_1ASK
0CLK299.4599.4799.47
1CLM298.5198.5198.54
2CLN297.5897.5297.61
3CLQ296.5496.5896.5
...
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.