Issue with datetime64 Conversion in Eikon API – Assistance Required

Vishwesh1
Vishwesh1 Newcomer
edited April 9 in Eikon Data APIs

Hello Eikon Developer Team,

I am encountering an issue when using the ek.get_news_headlines() function in the Eikon API. Recently, when fetching news headlines in my project, the following traceback error has started to occur:

Traceback (most recent call last):
File "main_8.py", line [105], in <module>
df_new = ek.get_news_headlines(
File "venv/lib/site-packages/eikon/news_request.py", line 126, in get_news_headlines
return get_data_frame(result)
File "venv/lib/site-packages/eikon/news_request.py", line 144, in get_data_frame
headlines_dataframe = pd.DataFrame([], numpy.array(first_created, dtype='datetime64'), Headline_Selected_Fields)
...
TypeError: datetime64 values must have a unit specified

It appears that the error is occurring during the conversion of datetime arrays. For context, I’m currently using NumPy version 1.26.2—which meets pandas’ dependency requirements (numpy>=1.22.4, <2.0). This issue did not occur in my previous setup, and I suspect it might be related to changes in how NumPy handles datetime64 dtypes (i.e., requiring an explicit time unit).

Could you please advise on the following:

  1. Is there a known compatibility issue with the current version of the Eikon API and NumPy 1.26.2?
  2. What version of NumPy is officially supported or recommended for use with the current version of the Eikon API?
  3. Would you recommend a temporary workaround (e.g., downgrading NumPy to an earlier version such as 1.22.4) until a patch is released, or is there another fix for this issue?

Thank you very much for your assistance and guidance on this matter.

Best regards,

Vishwesh1

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Vishwesh1

    Thank you for reaching out to us.

    I can replicate this issue. I saw this error when there is no returned headline.

    You can use the following statement to check the response.

    ek.set_log_level(1)
    
    ek.get_news_headlines('ORDER IMBALANCE', date_from='2024-10-19T00:00:00', date_to='2024-10-19T23:59:59', count=100)
    
    2025-04-09 12:47:38,054 P[19848] [MainThread 45536] HTTP Response code: 200
    2025-04-09 12:47:38,054 P[19848] [MainThread 45536] HTTP Response: {"headlines":[],"newer":"/headlines?payload=eyJxd…

    It will work fine if there are returned headlines.

    ek.get_news_headlines("ALL", count=100)
    

    You can try the LSEG Data Library for Python instead. The news example is on GitHub.