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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 0

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-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonapicommoditiesexpired-contract
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.

1 Answer

Upvotes
Accepted
39.2k 75 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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea