Expired contracts data using eikon api

Hi,

I am trying to get the data for 2019 August contract of Brent Crude oil. The code I have written is:

df, ek = e.get_data('LCOQ9^1',

['TR.SETTLEMENTPRICE .date','TR.SETTLEMENTPRICE '], {'SDate':'-3M', 'EDate':'0D' })

The output:

NaN TR.SETTLEMENTPRICE .DATE TR.SETTLEMENTPRICE

0 LCOQ9^1 NaN NaN


I have also used CLOSEPRICE in place of SETTLEMENTPRICE, but still getting NaN.

There is no error message.

I have referred to this post on the forum:

https://community.developers.refinitiv.com/questions/58620/request-expired-commodity-futures-with-get-data.html


Best Answer

  • Gurpreet
    Answer ✓

    Hello @varun.divakar

    I tried expanding the time range, and was able to get some data. Seems like you have to include the time range when this contract was active. See if this works for you.

    >>> ek.get_data('LCOQ9^1', ['TR.SETTLEMENTPRICE.date','TR.SETTLEMENTPRICE'], {'SDate':'-12M', 'EDate':'0D' })
    (    Instrument                  Date  Settlement Price
    0      LCOQ9^1  2019-04-30T00:00:00Z             71.45
    1      LCOQ9^1  2019-05-01T00:00:00Z             71.50
    2      LCOQ9^1  2019-05-02T00:00:00Z             70.02
    3      LCOQ9^1  2019-05-03T00:00:00Z             70.03
    4      LCOQ9^1  2019-05-06T00:00:00Z             70.37
    5      LCOQ9^1  2019-05-07T00:00:00Z             69.07
    6      LCOQ9^1  2019-05-08T00:00:00Z             69.62
    7      LCOQ9^1  2019-05-09T00:00:00Z             69.48
    8      LCOQ9^1  2019-05-10T00:00:00Z             69.64
    9      LCOQ9^1  2019-05-13T00:00:00Z             69.31
    10     LCOQ9^1  2019-05-14T00:00:00Z             70.31
    11     LCOQ9^1  2019-05-15T00:00:00Z             70.90
    12     LCOQ9^1  2019-05-16T00:00:00Z             71.70
    13     LCOQ9^1  2019-05-17T00:00:00Z             71.26
    14     LCOQ9^1  2019-05-20T00:00:00Z             71.16
    15     LCOQ9^1  2019-05-21T00:00:00Z             71.31
    16     LCOQ9^1  2019-05-22T00:00:00Z             69.99
    17     LCOQ9^1  2019-05-23T00:00:00Z             66.50
    18     LCOQ9^1  2019-05-24T00:00:00Z             67.47
    19     LCOQ9^1  2019-05-27T00:00:00Z             68.77
    20     LCOQ9^1  2019-05-28T00:00:00Z             68.67
    21     LCOQ9^1  2019-05-29T00:00:00Z             67.87
    22     LCOQ9^1  2019-05-30T00:00:00Z             65.33
    23     LCOQ9^1  2019-05-31T00:00:00Z             61.99
    24     LCOQ9^1  2019-06-03T00:00:00Z             61.28
    25     LCOQ9^1  2019-06-04T00:00:00Z             61.97
    26     LCOQ9^1  2019-06-05T00:00:00Z             60.63
    27     LCOQ9^1  2019-06-06T00:00:00Z             61.67
    28     LCOQ9^1  2019-06-07T00:00:00Z             63.29
    29     LCOQ9^1  2019-06-10T00:00:00Z             62.29
    ..         ...                   ...               ...
    251    LCOQ9^1  2020-04-15T00:00:00Z               NaN
    252    LCOQ9^1  2020-04-16T00:00:00Z               NaN
    253    LCOQ9^1  2020-04-17T00:00:00Z               NaN
    254    LCOQ9^1  2020-04-20T00:00:00Z               NaN
    255    LCOQ9^1  2020-04-21T00:00:00Z               NaN
    256    LCOQ9^1  2020-04-22T00:00:00Z               NaN
    257    LCOQ9^1  2020-04-23T00:00:00Z               NaN
    258    LCOQ9^1  2020-04-24T00:00:00Z               NaN
    259    LCOQ9^1  2020-04-27T00:00:00Z               NaN
    260    LCOQ9^1  2020-04-28T00:00:00Z               NaN
    261    LCOQ9^1  2020-04-29T00:00:00Z               NaN
    262    LCOQ9^1  2020-04-30T00:00:00Z               NaN
    263    LCOQ9^1  2020-05-01T00:00:00Z               NaN
    264    LCOQ9^1  2020-05-04T00:00:00Z               NaN
    265    LCOQ9^1  2020-05-05T00:00:00Z               NaN
    266    LCOQ9^1  2020-05-06T00:00:00Z               NaN
    267    LCOQ9^1  2020-05-07T00:00:00Z               NaN
    268    LCOQ9^1  2020-05-08T00:00:00Z               NaN
    269    LCOQ9^1  2020-05-11T00:00:00Z               NaN
    270    LCOQ9^1  2020-05-12T00:00:00Z               NaN
    271    LCOQ9^1  2020-05-13T00:00:00Z               NaN
    272    LCOQ9^1  2020-05-14T00:00:00Z               NaN
    273    LCOQ9^1  2020-05-15T00:00:00Z               NaN
    274    LCOQ9^1  2020-05-18T00:00:00Z               NaN
    275    LCOQ9^1  2020-05-19T00:00:00Z               NaN
    276    LCOQ9^1  2020-05-20T00:00:00Z               NaN
    277    LCOQ9^1  2020-05-21T00:00:00Z               NaN
    278    LCOQ9^1  2020-05-22T00:00:00Z               NaN
    279    LCOQ9^1  2020-05-25T00:00:00Z               NaN
    280    LCOQ9^1  2020-05-26T00:00:00Z               NaN