Failed returns on get_data

I have a routine that has been running fine for several months but now fails if I pass yesterdays date as a parameter, but if I pass the prior sessions date it works fine.

It seems that the data is not prepared for yesterday's session yet. Usually it runs successfully in the mid evening for New York and Toronto. Sometimes we need to wait, but it is always ready in the morning.

C:\PNC\Stats\Python>python.exe GetHighsLows.py High XNYS 20220418 -> FAILS

C:\PNC\Stats\Python>python.exe GetHighsLows.py High XNYS 20220414 ->SUCCEEDS

In ther traceback below, it suggests the header is not being found in yesterday's data.

Any ideas?


C:\PNC\Stats\Python>python.exe GetHighsLows.py High XNYS 20220418
Traceback (most recent call last):
  File "C:\PNC\Stats\Python\GetHighsLows.py", line 13, in <module>
    df, err = ek.get_data(instrument,['TR.CommonName','TR.PRICECLOSE'])
  File "C:\Users\PC3\AppData\Local\Programs\Python\Python39\lib\site-packages\refinitiv\dataplatform\legacy\data_grid.py", line 224, in get_data
    return get_data_frame(result, field_name)
  File "C:\Users\PC3\AppData\Local\Programs\Python\Python39\lib\site-packages\refinitiv\dataplatform\legacy\data_grid.py", line 278, in get_data_frame
    headers = [header["displayName"] for header in data_dict["headers"][0]]
KeyError: 'headers'
C:\Users\PC3\AppData\Local\Programs\Python\Python39\lib\site-packages\httpx\_client.py:2012: UserWarning: Unclosed <httpx.AsyncClient object at 0x000002814ED6A280>. See https://www.python-httpx.org/async/#opening-and-closing-clients for details.

Best Answer

  • Hi @dgarrard,

    I believe that this is a content-related question. The API is behaving as expected - I tested it myself.

    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.

Answers

  • Here is the script:

    import sys
    import refinitiv.dataplatform.eikon as ek
    import pandas
    ek.set_app_key()

    DataSwitch_T = sys.argv[1]  # High, Low
    Exch_T = sys.argv[2]   # XNYS, XTSE
    Date_T = sys.argv[3]   # 20211203

    # EIKON QUERY
    instrument = "SCREEN(U(IN(Equity(active,public,primary,countryprimaryquote))),IN(TR.ExchangeMarketIdCode,'" + Exch_T + "'),BETWEEN(TR.Price52Week"+DataSwitch_T+"Date," + Date_T + "," + Date_T + "))"
    df, err = ek.get_data(instrument,['TR.CommonName','TR.PRICECLOSE'])

    file1 = open('C:\PNC\Logs\MIA_'+DataSwitch_T+'_'+Exch_T+'_'+ Date_T +'.txt', 'w')

    df.to_csv(file1, index=False)
    file1.close()

    new_df = pandas.read_csv('C:\PNC\Logs\MIA_'+DataSwitch_T+'_'+Exch_T+'_'+ Date_T +'.txt')

    print('~Beginning of Data\n')
    print(new_df)
    print('\n~End of Data')


  • This was an Eikon service (not specifically API) outage which lasted for about 4 days. It has since come back on line.

  • Thank you for the feedback. It is very much appreciated.