question

Upvotes
Accepted
3 0 0 1

Historical pricing parallel request get_data_async closure

Hi there,

in the github library (Example.DataLibrary.Python/Examples/2-Content/2.01-HistoricalPricing/EX-2.01.02-HistoricalPricing-ParallelRequests.ipynb at main · LSEG-API-Samples/Example.DataLibrary.Python · GitHub)

the example given to send parallel requests for 3 names :

tasks = asyncio.gather(
    historical_pricing.events.Definition('VOD.L').get_data_async(closure='Vodafone'),
    historical_pricing.summaries.Definition('AAPL.O').get_data_async(closure='Apple'),
    historical_pricing.summaries.Definition('MSFT.O').get_data_async(closure='Microsoft')
)

If I want to send the historical_pricing.summaries.Definition().get_data_async for say 50 different equity names, how can i do it without writing "historical_pricing.summaries.Definition().get_data_async()" for each of the 50names? or do I have to specify it 50 times within the asyncio.gather function?


#technologypython apilseg-data-libraryparallel-run
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
Upvotes
Accepted
87.1k 294 53 79

@Joe_tan

Thank you for reaching out to us.

You need to have an array of RICs. The code looks like this:

ric_list = ['VOD.L','AAPL.O','MSFT.O','IBM.N']
task_list = [historical_pricing.summaries.Definition(ric).get_data_async() for ric in ric_list]
tasks = asyncio.gather(*task_list)


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.