The Query
I am using the lseg-data Python library ( https://pypi.org/project/lseg-data/ ). A few questions: 1. How do I retrieve quarterly financial data for a company? 2. In particular I am interested in segmented revenue data. Is TR.BGS.BusTotalRevenue the correct field to query or is it TR.F.PRDEXTREVASR? A lot of forum posts refer to TR.BGS.BusTotalRevenue but I cannot find this field in the Workspace Data Item Browser. 3. I've tried using lseg_data.get_history but I get a strange error (see attached screenshot)
@Siddhanth.V
Thank you for reaching out to us.
This forum is dedicated to software developers using LSEG APIs. The moderators on this forum do not have deep expertise in every bit of content available through LSEG products, which is required to answer content questions such as this one.
The best resource for content questions is the Helpdesk support team, which can be reached by submitting queries through LSEG Support. The support team will either have the required content expertise ready available or can reach out to relevant content experts to get the answer for you.
You need to ask for the Excel formula, such as =RDP.Data and =RDP.HistoricalPricing, that can be used to retrieve the required data. Then, we can help you converting that formula to Python code.
Hello @Jirapongse Good day! For the requested data you can use these data items- "TR.F.PeriodEndDate;TR.F.StatementDate;TR.F.statementheaders.StdCurr;TR.F.statementheaders.IndGroupGl;TR.F.PresentationFormat"
Please find the below sample Workspace excel formula which we are getting for all of the historical periods as well:
=@RDP
.Data("AAPL.O","TR.F.PeriodEndDate;TR.F.StatementDate;TR.F.statementheaders.StdCurr;TR.F.statementheaders.IndGroupGl;TR.F.PresentationFormat","Period=FQ0 Frq=FQ SDate=0 EDate=-4 CH=Fd RH=IN")
@UDAY_1
The Python code looks like this:
df = ld.get_data( universe = ['AAPL.O'], fields = ['TR.F.PeriodEndDate;TR.F.StatementDate;TR.F.statementheaders.StdCurr;TR.F.statementheaders.IndGroupGl;TR.F.PresentationFormat'], parameters = {'Period':'FQ0','Frq':'FQ','SDate':0,'EDate':-4}) df
The output is:
HI @Jirapongse Mr. Sean confirmed
Yes, I am aware of that. These parameters
parameters = { "FRQ": "FY", "SDate": "0", "EDate": "-10" }
were the ones I was first using before I opened this ticket. These parameters get me the correct results, which also include the FY2023 data.
But why do the parameters with the actual start and end dates
parameters={'Period': 'FY0', 'Frq':'FY', 'SDate':'2000-01-01', 'EDate':'2026-01-16'},
in the sample code snippet you gave me last week not returning FY2023 data?
I understand that the snippet you gave me was for pulling quarterly data. I just changed FRQ from FQ to FY to get fiscal year data instead. But can you point me to where I made a mistake in the fundamental_and_reference call for full fiscal year data that resulted in the missing data? Thanks
It is better to check the data in the Workspace Excel with the same instruments, fields, and parameters. For example:
=RDP.Data("4295903763","TR.F.RevGoodsSrvc","SDate=2000-01-01 EDate=2026-01-16 CH=Fd RH=IN,fperiod",B2)
The output in Excel doesn't have FY2023.
Please contact the Workspace Excel support team to verify it.
Hi @Jirapongse I have already provided the below code ld.get_data( universe = ['CMC'], fields = ['TR.F.RevGoodsSrvc.fperiod','TR.F.RevGoodsSrvc'], parameters = {'Period':'FY0','Frq':'FY','SDate':0,'EDate':-24})
For which client has responded. Thanks, but we've established last week that ld.get_data occasionally returns misaligned data right? Which is why you suggested to use fundamental_and_reference. So it seems like for certain companies/fields, get_data is better while for others fundamental_and_reference is better? Is there any way to use a single call that will consistently return the correct data for any company for any year?
The client can use the same universe, fields, and parameters in the fundamental_and_reference.Definition.
response= fundamental_and_reference.Definition( universe = ["CMC"], fields=['TR.F.RevGoodsSrvc.fperiod','TR.F.RevGoodsSrvc'], parameters = {'Period':'FY0','Frq':'FY','SDate':0,'EDate':-24} ).get_data() response.data.df
Thank you for the response @Jirapongse Client has a follow-up Where can we find documentation on lseg-data library in detail for the above parameters and fields?
The values in the fields and parameters are similar to the Workspace Excel.
The client can use the Formula Builder in the Workspace Excel or the Data Item Browser tool to search for fields and parameters
HI @Jirapongse Is there some sort of pdf documentation? E.g. on the parameters below, how do we know the allowed values and exact behavior?parameters = {'Period':'FY0','Frq':'FY','SDate':0,'EDate':-24})
It is the same parameter used in the =RDP.Data Excel formula.
=RDP.Data("4295903763","TR.F.RevGoodsSrvc;TR.F.RevGoodsSrvc.fperiod","SDate=0 EDate=-24 Period=FY0 Frq=FY CH=Fd RH=IN",B2)
We can address the coding-related questions. For content‑related inquiries, please contact the Workspace Excel team regarding the PDF documentation, allowed values, and expected behavior.
Hi, thanks for this. Is there any way to get this exact same table but also with Financial Period Absolute? e.g. a column with FY2025, FY2024, …
It could be like this:
df = ld.get_data( universe = ['AAPL.O'], fields = ['TR.F.PeriodEndDate;TR.F.PeriodEndDate.fperiod;TR.F.StatementDate;TR.F.statementheaders.StdCurr;TR.F.statementheaders.IndGroupGl;TR.F.PresentationFormat'], parameters = {'Period':'FQ0','Frq':'FQ','SDate':0,'EDate':-4}) df