Why do I get only N/A in the following code in Python?

import refinitiv.dataplatform.eikon as ek


import numpy as np # NumPy


import pandas as pd # pandas


import configparser as cp


import sys


ek.set_app_key('') # here I insert app_key


import eikon as ek

df_xls = pd.read_excel(r'C:\10K.xlsx')

mylist = df_xls['RIC'].tolist()

#print(mylist)


df, err = ek.get_data(

instruments = mylist,

fields = ['MEDIAN(TR.PtoEPSMeanEst(Period=NTM,Frq=W,SDate=2016-12-15,EDate=2021-12-14))']

)


display(df)



Below you could see the result of the script:

1639570285257.png

Tagged:

Best Answer

«1

Answers

  • Hi @susskaya.anita

    I used the code you provided and can get the data properly

    1639570751529.png

    Could you please try to print an error of get_data function using print(err) ?

    This could be the case that you don't have an access to this data, if so, please contact your account owner regarding the entitlement or if it's any other issue, you may put the error message here and we will investigate more.

  • [{'code': 100, 'col': 1, 'message': 'Asynchronous Query library internal error.', 'row': 0}, {'code': 100, 'col': 1, 'message': 'Asynchronous Query library internal error.', 'row': 1},...


    it is the error

  • It seems that it does not uderstand properly the values from xls. I don't know why.

  • I don't think that the problem is in the access because via Excel add-in I could retrieve that data
  • Hi @susskaya.anita

    Your XLS filename suggests you have 10K instruments in the list. If this is the case, have you tried with a smaller list of instruments in an excel file?

    If you have tried a smaller list and it still fails, please convert the shorter excel file to a CSV file and attach it here so the above code snippet can be tested with your list.

  • You were right. The decrease of number of RIC-codes helped. However, what is the limit? Only 100 or what?
  • Hi @susskaya.anita

    The following page explains the various types of limits enforced with the Eikon Data API

    Eikon Data API Usage and Limits Guideline


  • get_data: The current limit value (10-Oct-2019) is around 10,000 data points.


    But I did not exceed that limit. Moreover, I did not have errors which are mentioned in the guideline

  • raksina.samasiri, I have the same issue starting this week and I had some research. This issue reproduces time from time and possibility depends on the amount of data.

    The code:

    for RIC_num in [10,100,500]:

    for n_cols in [10, 20]:

    RIC_list = ric.RIC.tolist()[:RIC_num]

    columns = columns_list[:n_cols]

    print('RIC length:', len(RIC_list))

    print('columns length:', len(columns))

    for i_ in range(10):

    data, err = ek.get_data(RIC_list, columns)

    if err is None:

    print('No error', datetime.now())

    else:

    print(set([e['code'] for e in err]), end=' ')

    if 100 in set([e['code'] for e in err]):

    print('<--- This error!', datetime.now())

    else:

    print(datetime.now())


    The output (partly):

    RIC length: 100
    columns length: 20
    {251658243} 2021-12-16 17:47:00.936565
    {251658243} 2021-12-16 17:47:08.035268
    {100} <--- This error! 2021-12-16 17:47:30.244498
    {100} <--- This error! 2021-12-16 17:47:50.696324
    {251658243} 2021-12-16 17:47:57.530822
    {251658243} 2021-12-16 17:48:05.015905
    {100} <--- This error! 2021-12-16 17:48:40.422272
    {251658243} 2021-12-16 17:48:50.582018
    {251658243} 2021-12-16 17:48:58.884504
    {251658243} 2021-12-16 17:49:08.098476


    Here you can see 3 fails for 100 RICs and 20 columns.
    In case of 500 RICs with 20 columns it fails in 8 out of 10 attempts:

    RIC length: 500
    columns length: 20
    {100} <--- This error! 2021-12-16 17:50:49.137280
    {100} <--- This error! 2021-12-16 17:51:10.376004
    {251658243} 2021-12-16 17:51:32.593595
    {251658243} 2021-12-16 17:51:55.249686
    {100} <--- This error! 2021-12-16 17:52:16.634033
    {100} <--- This error! 2021-12-16 17:52:37.690012
    {100} <--- This error! 2021-12-16 17:52:58.664758
    {100} <--- This error! 2021-12-16 17:53:19.581651
    {100} <--- This error! 2021-12-16 17:53:40.567594
    {251658243} 2021-12-16 17:54:03.253674


    I used to work with 3000 rows and it worked fine till before.

  • Hi @susskaya.anita

    I have reported this issue to the Eikon Data API team for their input.

    I will report back once I hear from them.

  • Hi @susskaya.anita and @malashenko.i.o

    The EDAPI team have asked if you can generate logs?

    import logging
    ek.set_log_level(logging.DEBUG)

    ek.set_app_key('your app key')

    and then running your script should generate a file something like pyeikon.20211217.15-28-56.log

    please remove any credential information from the log file - before uploading.

    e.g.

    headers = {'x-tr-applicationid': 'your appkey'}

    and

    access_token":"eyJhbGciOiJIUzI1NiIsInR.......'

    NOTE: There may well be multiple entries like the above in your log file

    please search and remove all of them before uploading.


  • Hi @malashenko.i.o - thanks will pass this on.
  • I am experiencing similar issues.

    Snippets that worked without any problems for years keep throwing this error when calling ek.get_data:

    Error code 100 | Asynchronous Query library internal error.

    As far as I can tell the problems started on December 10th.

    Lowering the number of instruments/fields seems to reduce the error rate. However, even when using moderately sized requests the mentioned error occurs occasionally.


  • the same error I usually see

  • Hi @susskaya.anita , @malashenko.i.o and @gabriel.g

    I have copied your messages and log files to the Eikon API team.

    I will update once I hear from them.


  • Thank you! I will wait then!
  • Thank you so much for raising a ticket for me!

  • I checked the script using 1500 RICs and get NA as well. Tried the same with TR.PtoEPSMeanEst only and get all results.

    My assumption is that for MEDIAN(TR.PtoEPSMeanEst(Period=NTM,Frq=W,SDate=2016-12-15,EDate=2021-12-14)) calculation, python needs to get all data points to calculate MEDIAN, so 261 separate values for each RIC that is why the limit is exceeded. Why the error message doesn't indicate the exceeded limit? I don't know,...


  • I don't think there is a limit restriction, because, as I posted below, you could try to get the same data in a loop and it could work sometimes (possibility depends on how big your query is). In case of limits there would be no chance for this.
  • As you know via Formula Builder I could get results using this formula for 7500 RIC-codes. I don' think that via Formula Builder we could get more than via Python.

  • So why if we change the Frq from W to Y we can get all the results? I tested it for 1500 RICs and worked well
  • Hi @lukasz.trzcinski0 - Are you referring to two different limits - one being the Eikon API limits as defined on the https://developers.refinitiv.com/en/api-catalog/eikon/eikon-data-api/documentation and another being the limitation of the MEDIAN call - on the backend system that EDAPI uses perhaps?

    @malashenko.i.o , @gabriel.g and @susskaya.anita - Can you please confirm which country you are located in - so the EDAPI team can confirm which servers your EIKON is connecting to. - in case there is a server-side issue.

    UPDATE: No need for pip freeze output. It appears the problem is server-side.

    Please still confirm your location so we can identify the servers.

    Thanks.


  • Russia, Saint Petersburg
  • Austria, Vienna
    connecting via EMEA servers

  • Hi @susskaya.anita , @gabriel.g and @malashenko.i.o

    Your tickets should be re-assigned to the server team - who will work with the EDAPI team to investigate further.

    Hopefully, the support team will keep you updated on the progress.,

  • Has this already been resolved? I am getting similar error messages:

    "Asynchronous Query library internal error."