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?


Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @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)