get_data suddenly returns multiple lines

I run this with the eikon python api:

ref, e = ek.get_data(['PAZ2'],['TR.SETTLEMENTPRICE', 'TR.AMERICACLOSEBIDPRICE', 'TR.CLOSEPRICE', 'TR.OPENINTEREST', 'TR.ACCUMULATEDVOLUME'] , {'SDate': '2022-03-31', 'EDate': '2022-03-31', 'Frq': 'D'})

print(ref.to_string());

It always returned one line but since this week it suddenly returned multiple lines. Why is that?



Tagged:

Best Answer

  • raksina.samasiri
    Answer ✓

    hi @quan.zheng

    As checked, the output dataframe returns 3 lines because there are multiple Period End Dates in fields TR.CLOSEPRICE and TR.ACCUMULATEDVOLUME (which are 29th, 30th, 31st March 2022)

    However, changing the parameter to the code below returns only one row of dataframe

    ref, e = ek.get_data(['PAZ2'],['TR.SETTLEMENTPRICE', 'TR.AMERICACLOSEBIDPRICE', 'TR.CLOSEPRICE', 'TR.OPENINTEREST', 'TR.ACCUMULATEDVOLUME']
    , {'SDate': '2022-03-31'})

    print(ref.to_string())

    The output is

      Instrument  Settlement Price  America  Close Bid Price  Close Price  Open Interest  Accumulated Volume
    0 PAZ2 2255.1 <NA> 2182 3 4

    For the clarification of the content, as this forum is dedicated to software developers using Refinitiv APIs and the moderators on this forum do not have deep expertise in every bit of content available through Refinitiv products, which is required to answer content questions such as this one.

    The best resource for content questions is the Refinitiv Helpdesk, which can be reached by either calling the Helpdesk number in your country or submitting a new ticket to the support team via MyRefinitiv.

    However, for this case, ticket number 11108282 was raised on your behalf and the support team is going to email you soon for the clarification of this

Answers

  • Hi @quan.zheng,


    This is because several Close Prices were returned this time because they were calculated at different times. This may not always happen, meaning that you might often only get one calculation for Close Price, and thus one row only. You may verify this with the code below:


    ref, e = ek.get_data(
    ['PAZ2'],
    ['TR.SETTLEMENTPRICE.date',
    'TR.SETTLEMENTPRICE',
    'TR.AMERICACLOSEBIDPRICE.date',
    'TR.AMERICACLOSEBIDPRICE',
    'TR.CLOSEPRICE.date',
    'TR.CLOSEPRICE.calcdate',
    'TR.CLOSEPRICE',
    'TR.OPENINTEREST.date',
    'TR.OPENINTEREST',
    'TR.ACCUMULATEDVOLUME.date',
    'TR.ACCUMULATEDVOLUME'],
    {'SDate': '2022-03-31',
    'EDate': '2022-03-31',
    'Frq': 'D'})

    print(ref.to_string())


                    Date   Calc Date  Close Price
    2022-03-29T00:00:00Z 2022-03-29 2182
    2022-03-29T00:00:00Z 2022-03-30 2182
    2022-03-29T00:00:00Z 2022-03-31 2182


    This time, the calculation at different times rendered the same Close Price, but it might not always (although it does nearly all the time).


    I would suggest you always take the last Close Price shown unless you are backtesting strategies and building scenario analyses putting yourself in the shoes of someone with information as of 2022-03-29, then please use the Close Price as of Calc Date 2022-03-29.