Can I get historical data for a chain by specifying SDate, EDate?

Hello

I know I can use :

df= ek.get_data(['CFI2K1'], ['TR.CLOSEPRICE.date', 'TR.CLOSEPRICE.value'], {'SDate': '2021-03-01', 'EDate': '2021-04-21'})

to get data for a specific RIC, but what happens if I have a chain

0#CFI2:

which includes the above RIC(CFI2K1) along with CFI2M1,CFI2N1,....etc

Can I do the same thing with one request, without having to make a request for each included RIC separately?

Thank you

Best Answer

  • @sfaka try this:

    df,err = ek.get_data(['0#CFI2:'],'CF_NAME')
    chain = df['Instrument'].astype(str).values.tolist()
    df

    image

    df, err= ek.get_data(chain, ['TR.SETTLEMENTPRICE.date','TR.SETTLEMENTPRICE.value'], {'SDate': '2021-03-01', 'EDate': '2021-04-21','Frq':'D'})
    df

    image

Answers

  • Thank you Jason

  • Actually this will only for work for/near the current date, where the 'active' RICs are correct for these dates.

    How should I change this to get historical data for all months from 1-jan-2019 until 1-jan-2020?

    Thank you.

  • @sfaka So you need to create the expired RICs programatically using the following guidance:

    image

    image

    So in your case: CFI2 is the ric root, say U is for Sept, 2020 should be 0, and decade is 2. Putting this together we have an expired RIC of CFI2U0^2 for the Sept 2020 contract - try viewing a chart in eikon with that RIC to confirm.

    So you can programatically recreate all the expired RICs you need and then request data for them. I hope this can help.

  • Yes this is perfect.

    Where can I read about these things to get more familiar with Eikon?

    Also is there a way to get for CFI2c1 all prices for 2018-2020 with the respective contract month of each price? You can just point me to the page I should read about this.

    Thank you again.

  • @sfaka good news - so the expired futures guidance I posted came from a page in Eikon - it just had what I posted - you can find it by typing expired futures into Eikon search. There used to be a book many years ago which detailed some of this stuff but we havent produced those in decades.

    Regarding continuous futures we have vanilla c1,c2,..cn front month futures for this RIC. This will give you a historic series of front month prices. CFI2c1, CFIc2 ... CFI2cn. Here the contract roll is the expiry date. For some (cash settled) contracts such as index futures we also have a continuous future that rolls when the volume in the new contract exceeds the old, for example EScv1 for S&P500 futures. But its not available for this type of contract.

    If you have specific content questions please contact the helpdesk with a content query - they are usually very responsive. I will ask some of my colleagues if they know of more documentation - and post that here if they have any. We also have a number of in product content guides - just type guides into eikon search bar or energy guide to be more specific. Other than that there are plenty of resources and detailed explanations about various content sets/asset classes in our developer articles. We also have a number of python tutorials for the Eikon Data API here.

    I hope this can help.

  • @sfaka It might be helpful for us to know exactly the kind of documents you would expect to see for content guides etc. We can then put that to the content teams and ask them to create that,

  • @jason.ramchandani

    I have written some code using the Eikon API but all of it comes from copying other code and then trial and error.

    Recently I found out what XXXc1 (usually?) means, just today I learned how expired contracts' RICs are formed and 2 days ago I understood that CF_CLOSE gives the latest price, why SDate does not work for all fields and how to use Data Item Browser to find more Parameters.

    So the kind of guide I was looking for as an inexperienced user would include such information in more detail, cause I am sure I am still missing a lot of pieces.

    Maybe the tutorials(which I havent been through yet) will help. They seem really interesting and will check them for sure.

    Thank you again for your time and help.