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 futures chain (expired and current) & get all historical prices

Hi,


I would like to pull a futures chain, including expired contracts (say 0#C) and current contracts. And get the prices. Is there a simple way to do this that pulls them in a single dataframe once you have the list of contracts?

pythoncommodities
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
Accepted
2.3k 16 2 2

Hi @Shadeun,

The Search API is what you're after. How many are you expecting to retrieve in one call? are we talking 1k or 100 million rows?

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,

Would be a lot, perhaps 1k rows per contract and 100 contracts historically, so 100k 'cells'. But not an unrealistically large number of datapoints i think.

So you are suggesting i use the search function to find the contracts and then pull via ek.get_data?

Yes, I'd suggest that, although you don't have to use ek.get_data, you can keep with rd, which also has a get data function. you can find more details here (as well as many examples in CodeBook).

the search limits itself to 10k rows; for more, I'd advise bulking your search (e.g.: by maturity). There is a way to do just this as shown here and explained in the 'Building Search into your Application Workflow' article.

When it comes to expired instruments, I'd suggest reading this great article too.

Shadeun avatar image Shadeun jonathan.legrand

Thanks i was hoping something that merged Pull All Expired Contracts - Forum | Refinitiv Developer Community and an active one.

I cannot seem to get the code in the link to work however. i assume rdp is always

import refinitiv.dataplatform as rdp

yeah?

Show more comments
Upvotes
5.8k 10 5 8

Hi @Shadeun ,

Is this what you're looking for?

df, err = ek.get_data('0#C:',['TRDPRC_1','OPINT_1','EXPIR_DATE'])
df

1658742607478.png

where

  • TRDPRC_1 is the Last trade price or value
  • OPINT_1 is an Open interest
  • EXPIR_DATE is the date on which the future, option or warrant expires

To find the field name to be used, Data Item Browser (DIB) in Refinitiv Workspace/Eikon Desktop can be used, here's the video regarding DIB tutorial.

Hope this helps and please let me know in case there is any further question


1658742607478.png (39.0 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.