question

Upvotes
Accepted
7 1 0 4

Efficiently querying multiple tickers in one query

In the function refinitiv.data.get_history I can query data for multiple RIC's at the same time, however, under the hood, there is a for loop that requests the data for each ticker separately, eating up 1 API call per RIC instead of per query in my API call limit (grabbing the last 1min bar for 100 futures RIC's eats up 100 api calls per minute).


In refinitiv.data.content._historical_data_provider.py, line 98 (refinitiv-data version 1.5.0):

def get_data(self, *args, **kwargs) -> Response:
    universe: List[str] = kwargs.pop("universe", [])
    entire_data_provider = get_entire_data_provider(kwargs.get("__content_type__"))

    with ThreadPoolExecutor(thread_name_prefix="HistoricalRequestThread") as ex:
        futures = []
        for inst_name in universe:
            fut = ex.submit(
                entire_data_provider.get_data,
                partial(super().get_data, *args),
                universe=inst_name,
                **kwargs,
            )
            futures.append(fut)


Is there a way to avoid the loop in bold?


An alternative solution would be to stream the futures 1min bars, if implemented (see my other question here)

pythonworkspace-data-api#technology#productrefinitiv-data-platformpython apirefinitiv-data-platform-libraries
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.

Upvote
Accepted
5.8k 18 2 7

Hi @pvklooster,


Thank you for your question. Checked with the team and I am afraid there is no way to avoid the loop you are referring to. Did you have a chance looking at the Stream Recorder examples within the RD Libraries:

Example.DataLibrary.Python/Examples/1-Access/EX-1.01.04-PricingStream-Recorder.ipynb at main · LSEG-API-Samples/Example.DataLibrary.Python (github.com)

You may open a stream, record the ticks in some duration and resample them in 1min intervals or recored them in 1min frequency and request the history after the record duration.

Please try this, if not already, and let as know what you think?


Best regards,

Haykaz

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
7 1 0 4

Thank you Haykaz - I haven't looked at the stream recorder, I will do so.

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.