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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 1 1

Pull All Expired Contracts

Is there a way to pull all expired contracts for a commodity? The same process is fairly straightforward for active contracts, but I haven't been able to find a simple method for expired contracts. If none exist, is there a means of pulling expiry dates for all active contracts?

eikoneikon-data-apipythonworkspaceworkspace-data-apirefinitiv-dataplatform-eikonapicommoditiesexpired-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.

1 Answer

Upvotes
Accepted
39.3k 76 11 27

Here's an example retrieving all expired CBOT corn futures. The result set contains one incorrect item (CH8). All expired future RICs contain carat symbol (^). You can filter out incorrect item that doesn't contain carat in the RIC name from the result set returned from the search.

rdp.search(
    view = rdp.SearchViews.CommodityQuotes,
    filter = ("ExchangeCode eq 'CBT' and AssetCategory eq 'CMF' and " +
              "PrimaryChainRIC eq '0#C:' and ExpiryDate lt 2021-02-05"),
    select = "RIC,ExpiryDate",
    top  = 1000)

For more info on using RDP Library to perform various types of searches see the article titled "Building Search into your Application Workflow".

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.