c1 futures historical underlying contract and expiry

Want to get timeseries with the underlying contract RIC for a continuous future, for example CLc1, for each given date in my specified period. Ideally want this for CLc1-CLc2 or equivalent in other future. End goal is to get timeseries with roll contract close, volume as well as volume as OI for each of the two underlying futures legs for each give date for at least 5 years back.

For example tried df,err= ek.get_data("CLc1", ["EXPIR_DATE.date", "EXPIR_DATE"], {'SDate':'2019-05-01', 'EDate':'2019-05-30'}) to get timeseries for CLc1 expiry date but not working.

Alternative to full timeseries would be to specify date, not just default on current.

All in Eikon API for Python.

Best Answer

  • chavalit-jintamalit
    Answer ✓

    I am not a content expert, so I am not sure if this is the information you are looking for.

    I think you can retrieve futures RIC codes from this:

    df,e = ek.get_data('0#CL:','LINK_1')
    rics = df['Instrument'].tolist()
    rics


    Which gives you a list of 128 RIC codes.

    ['CLN0', 'CLQ0', 'CLU0', ...,  'CLZ30', 'CLF31', 'CLG31']


    Then on each RIC, you can retrieve timeseries data:

    This is an example using RIC code at index 0 from rics list(which is CLN0).

    image