question

Upvotes
Accepted
11 0 0 5

Synchronous method with asynchronous map

Hi, I'm using the Refinitiv Data Plataform for python and I was wondering if there is any, functional or structural, difference between use map_async with rdp.HistoricalPricing.get_summaries insted of

rdp.HistoricalPricing.get_summaries_async with asyncio.

pythonrdp-apiasynchronous
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.

1 Answer

· Write an Answer
Upvote
Accepted
32.2k 41 11 20

Hello @sylvio.campos ,

Let me try to help:

Please refer to example Example.RDPLibrary.Python/2.1.0 - Content - HistoricalPricing - Synchronous.ipynb to see an example of get_summaries synchronous call.

Please refer to example Example.RDPLibrary.Python/2.1.1 - Content - HistoricalPricing - Asychronous.ipynb to see asynch call parallelized:

tasks = asyncio.gather(
    rdp.HistoricalPricing.get_events_async('VOD.L'),
    rdp.HistoricalPricing.get_summaries_async('VOD.L', interval = rdp.Intervals.TEN_MINUTES),
    rdp.HistoricalPricing.get_summaries_async('VOD.L', interval = rdp.Intervals.DAILY)    
)

asyncio.get_event_loop().run_until_complete(tasks)
historical_events, intraday_summaries, interday_summaries = tasks._result

print("\nHistorical Pricing Events")
display(historical_events.data.df)

print("\nHistorical Pricing Summaries - Intraday")
display(intraday_summaries.data.df)

print("\nHistorical Pricing Summaries - Interday")
display(interday_summaries.data.df)

The synch call returns once the processing is completed and if you have several calls to run, they would have to be run sequentially.

With asynch, if you have several calls to run, allows you to start them in parallel and run until they are complete.

Hope that this information is of help, and additionally, would suggest to consider Refinitiv Data Library Python, the next generation of RDP Library currently in pre-release with complete deck of starter examples made available on GitHub https://github.com/Refinitiv-API-Samples/Example.DataLibrary.Python and documentation on dev portal:

Refinitiv Data Library for Python

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.

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.