New posts are disabled while we improve the user experience.

You can browse the site, or for urgent issues, raise a query at MyAccount.

question

Upvotes
Accepted
4 4 9 11

Support for asyncio via Python

Hi, could I check if there is anyone who has experience using, or knows how to use the Eikon API with the asyncio package for Python?

eikon-data-apipython#technologyasynchronous
icon clock
10 |1500

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

Upvotes
Accepted
87.8k 294 53 79

@wesley.ng

Eikon Data API doesn't provide async interfaces. However, you can run it in an executor. For example:

import eikon as ek
import asyncio

def set_app_key(app_key):
    ek.set_app_key(app_key)

def get_data(instruments, fields, condition=None):    
    df, err = ek.get_data(instruments,fields,condition)
    return df

def get_timeseries(instruments, fields, start_date, end_date, interval="daily"):   
    df  = ek.get_timeseries(instruments, fields, start_date, end_date, interval)
    return df

async def main():    
    loop = asyncio.get_running_loop();     
    await loop.run_in_executor(None, set_app_key,"<App key>")   
    df = await loop.run_in_executor(None, get_data, ["IBM"],["TR.PriceClose"])
    print(df)
    df = await loop.run_in_executor(None, get_timeseries, ["PTT.BK"],"*","2022-01-01","2022-01-31")
    print(df)

asyncio.run(main())



icon clock
10 |1500

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

Upvotes
19.2k 86 39 63

Hi @wesley.ng

You can find an async example using the Refinitiv Data Library for Python here: Example.DataLibrary.Python/EX-2.01.02-HistoricalPricing-ParallelRequests.ipynb at main · Refinitiv-API-Samples/Example.DataLibrary.Python · GitHub

icon clock
10 |1500

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

Hi @nick.zincone, thanks for this. What about for the Eikon data API?

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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