question

Upvotes
Accepted
1 0 1 2

Async retrieval of Quarterly and Period Data

Hi everyone,

I have a question regarding data retrieval by periods. Over here, is the equivalent of what I am trying to do, just that it is using get_data() instead of get_data_async(). This is an example that I can't make asynchronous:

quarterly_revenue = rd.get_history(
        universe=[f"{ticker}"],
        fields=["TR.Revenue"],
        parameters={'Period': period},
        start=str(year),
        end=str(year),
    );
# Where Period is in the format: FQ-4, FQ-3 , etc
# Data is being retrieved for each quarter of the year this way

And another:

profitability_analysis = rd.get_history(
        universe=[f'{ticker}'],
        fields=['TR.F.IncAfterTaxMargPct','TR.RevenueActValue','TR.F.TotAssets','TR.F.LTDebtPctofTotEq','TR.F.TotDebtPctofTotEq'],
        parameters={'Period': f"FY{yq_counter}"},
    );
# Where Period is in the format: FQ-4, FQ-3 , etc


Thanks!

pythonworkspace#technologyrdp-apirefinitiv-data-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.

1 Answer

· Write an Answer
Upvote
Accepted
6.9k 21 3 6

Hi @vishal.nanwani,

Looking into (i) "EX-2.01.01-HistoricalPricing.ipynb", (ii) "EX-2.01.02-HistoricalPricing-ParallelRequests.ipynb", (iii) "Summary of Common LSEG Refinitiv APIs", and (iv) "LSEG’s Refinitiv Data Library for Python and its Configuration Process", I came up with the below, does it answer your question?



# ld.close_session()
# pip install lseg.data
import lseg.data as ld
from lseg.data.content import historical_pricing
import asyncio
# ld.open_session(
#     config_name="C:\\Example.DataLibrary.Python-main\\Configuration\\lseg-data.config.json",
#     name="platform.ldp6")
ld.open_session()


tasks = asyncio.gather(
    historical_pricing.events.Definition(
        universe=["LSEG.L"],
        count=10,
        fields=["BID", "ASK"],
        start="2024-08-19",
        end="2024-08-21"
        ).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')
)


await tasks
def display_reponse(response):
    print(response)
    if len(response) == 1:
        response = response[0]
    print("\nReponse received for", response.closure)
    if response.is_success:
        display(response.data.df)
    else:
        print(response.http_status)
vodafone = tasks.result()
display_reponse(vodafone)


1724229040390.png



1724229040390.png (22.9 KiB)
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.