Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
21 0 1 5

Need EOD closing and settlement prices day wise data for CL Options Contract

Need EOD closing and settlement prices day wise data for CL Options Contract . Also need information of deriving the the same prices data for expired option contracts . Need all the above info for NG also so kindly let know on generic basis

api#content
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.

Hello @peeush

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS


Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

1 Answer

· Write an Answer
Upvotes
Accepted
5.3k 16 2 7

Hi @peeush ,


For the active contracts what you can do is to use chains to expand the constituents, then request prices on those:

import refinitiv.data as rd
from refinitiv.data.discovery import Chain
cl_chain = Chain('0#CL+').constituents
print(cl_chain)
['0#CLF24+', '0#CLG24+', '0#CLH24+', '0#CLJ24+', '0#CLK24+', '0#CLM24+', '0#CLN24+', '0#CLQ24+', '0#CLU24+', '0#CLV24+', '0#CLX24+', '0#CLZ24+', '0#CLF25+', '0#CLG25+', '0#CLH25+', '0#CLJ25+', '0#CLK25+', '0#CLM25+', '0#CLN25+', '0#CLQ25+', '0#CLU25+', '0#CLV25+', '0#CLX25+', '0#CLZ25+', '0#CLF26+', '0#CLG26+', '0#CLH26+', '0#CLJ26+', '0#CLK26+', '0#CLM26+', '0#CLN26+', '0#CLQ26+', '0#CLU26+', '0#CLV26+', '0#CLX26+', '0#CLZ26+', '0#CLF27+', '0#CLG27+', '0#CLH27+', '0#CLJ27+', '0#CLK27+', '0#CLM27+', '0#CLN27+', '0#CLQ27+', '0#CLU27+', '0#CLV27+', '0#CLX27+', '0#CLZ27+', '0#CLF28+', '0#CLM28+', '0#CLZ28+', '0#CLM29+', '0#CLZ29+', '0#CLM30+', '0#CLZ30+', '0#CLM31+', '0#CLZ31+', '0#CLM32+', '0#CLZ32+', '0#CLM33+', '0#CLZ33+', '0#CLM34+', '0#CLZ34+']

This will return the monthly contract chains. Then you can expand those further to get contracts with specific strikes and get prices on those. E.g for '0#CLF24+':

cl_chain_F = Chain('0#CLF24+').constituents
rd.get_history(cl_chain_F, fields = ['SETTLE', 'TRDPRC_1'])


screenshot-2023-12-13-at-164232.png

As for the expired ones, those are not accessible directly and you need to reconstruct them following the RIC construction Rules. You can reach out to Helpdesk for more details by posting a question.


Hope this helps.


Best regards,

Haykaz


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.

Thanks for replying Haykaz, however i'm getting issues while trying to get a particular period data , that too in valid contract .. using ->

df = rd.get_history(cl_chain, fields = ['SETTLE', 'TRDPRC_1'], interval='daily', start = '2023-12-06', end = '2023-12-16')

getting error :

File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\refinitiv\data\_access_layer\get_history_func.py", line 166, in get_history

raise RDError(-1, except_msg)

refinitiv.data._errors.RDError: Error code -1 | No data to return, please check errors: ERROR: No successful response.

(TS.Interday.UserRequestError.70005, The universe is not found)


please assist

Hi @peeush ,


Assuming you kept my variable names, you should have run this with cl_chain_F not with cl_chain. cl_chain still consists of chains, so you will need to get its constituents (see the seconsd snippet of my code above) before running the get_history request.


Best regards,

Haykaz

Many a times I'm getting issues ...the command is sometimes running fine but sometimes just hungs up and gives server error 500 or bad request error ....can you please assist to resolve these issues.....i am told That is when server is overloaded with many requests...

Hi @peeush ,


you can consider wrapping the API request in try except statement and retrying a couple of times. This may help avoid temporary sever overloads

max_retries = 3
retries = 0
while retries<max_retries: 
    try:
        # API call goes here
        break
    except Exception as e: 
        print(retries, e)
        retries +=1
        #time.sleep(5)
        continue
data_root_1 

Hope this helps.


Best regards,

Haykaz

how to fetch the RIC root dynamically for any asset ....i need to know e.g. i have nifty index ...how will i find the RIC root for nifty index through api or any other medium ....second there is one info decade of the expiry of contract used for creating ric's for expired contracts for futures ....what is that ?

Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.