For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
39 1 0 4

Suppress error text while requesting data in Eikon API

I am testing the validity of a RIC trying both "try.. Except" (as suggested also here) and "With Suppress" functions to continue the loop and get correct RICs into a list. Although, the code works and adds correct RICs to the list I still see the message telling the RIC is incorrect. Please see attached the screenshot and putting one of them here below as well: try_except.png

RICs = ['NDXl1721A8290.U^L21', 'NDXl1721A8275.U^L21', 'NDXd1621A6275.U^D21','NDXd1621A6300.U^D21']

valid_rics = []

for RIC in RICs:

with suppress(ek.EikonError):

a = ek.get_timeseries(RIC, fields = ['CLOSE'], start_date = '2021-01-01', end_date ='2021-04-18',interval='daily' )

valid_rics.append(RIC)

valid_rics

Is there a way to hide that? Please also note that error text appeared while using the loop and it is ignored when the code is run without a loop for a single RIC.

I would appreciate if you help to find a way of suppressing error message while using the loop.


rics
try-except.png (64.5 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
4.3k 2 4 5

Hi @haykaz.aramyan,

Messages arn't displayed because of an EikonError exception, it's logged as warnings.
That's why "with suppress(ek.EikonError)" has no effect.

There is mainly 3 options to stop warning at screen:

  1. Disable all warnings (from any lib):
    import warnings
    warnings.filterwarnings("ignore")
  2. Disable displayed warnings from eikon:
    import logging
    import eikon as ek
    ...
    ek.set_app_key("xxxxxxxxxx")
    logger = logging.getLogger("pyeikon")
    logger.propagate = False
    ...
  3. Reduce log level to ERROR (warnings will be ignored):
    import logging
    import eikon as ek
    ...
    ek.set_app_key("xxxxxxxxxx")
    ek.set_log_level(logging.ERROR)
    ...
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
39 1 0 4

Hi @pierre.faurel ,

Thank you for your reply, that was very helpful, 2nd solution solved my problem.

Best regards,

Haykaz

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea