Fetching quarterly results

Hide code cell content
import refinitiv.data as rd

rd.open_session()
/home/runner/.local/share/virtualenvs/refinitiv-data-python-cookbook-I-HIyNf4/lib/python3.10/site-packages/refinitiv/data/_access_layer/session.py:71:FutureWarning: 
You open a platform session using the default value of the signon_control parameter (signon_control=True).
In future library version v2.0, this default will be changed to False.
If you want to keep the same behavior as today, you will need to set the signon_control parameter to True either in the library configuration file
({'sessions':{'platform':{'your_session_name':{'signon_control':true}}}}) or in your code where you create the Platform Session.
These alternative options are already supported in the current version of the library.
<refinitiv.data.session.Definition object at 0x7f3c18b0cfd0 {name='rdp'}>

You can use the Refinitiv Data Library for Python to retrieve quarterly results that company’s post each earnings season.

To do so, pass the company’s Refinitiv Instrument Code to the get_data submodule. In addition to the code, you must provide custom parameters that specify the metric, time interval and number of periods to retrieve.

Earnings per share

Here’s how to retrieve earnings per share for the last eight fiscal quarters for Thomson Reuters.

First define the metric you want to retrieve, followed by the time interval and number of periods in parenthesis.

expression = "TR.EPSFRActValue(SDate=0,EDate=-8,Period=FQ0,Frq=FQ)"

Then query the data for the company, asking for the metric as well as the date it was released and the last fiscal quarter’s end date.

rd.get_data(
    "TRI.TO",
    fields=[
        f"{expression}.Date",
        f"{expression}.periodenddate",
        expression,
    ],
)
Instrument Date Period End Date Earnings Per Share Reported - Actual
0 TRI.TO 2024-02-08 06:30:00 2023-12-31 1.48954
1 TRI.TO 2023-11-01 06:30:00 2023-09-30 0.8
2 TRI.TO 2023-08-02 06:30:00 2023-06-30 1.9
3 TRI.TO 2023-05-02 06:30:00 2023-03-31 1.64945
4 TRI.TO 2023-02-09 06:30:00 2022-12-31 0.61206
5 TRI.TO 2022-11-01 06:30:00 2022-09-30 0.48757
6 TRI.TO 2022-08-04 06:30:00 2022-06-30 -0.24897
7 TRI.TO 2022-05-03 06:30:00 2022-03-31 2.13703
8 TRI.TO 2022-02-08 06:30:00 2021-12-31 -0.37346

Revenue

The same logic can be used to query revenue, which is provided by the “TR.RevenueActValue” field.

expression = "TR.RevenueActValue(SDate=0,EDate=-8,Period=FQ0,Frq=FQ)"

rd.get_data(
    "TRI.TO",
    fields=[
        f"{expression}.Date",
        f"{expression}.periodenddate",
        expression,
    ],
)
Instrument Date Period End Date Revenue - Actual
0 TRI.TO 2024-02-08 06:30:00 2023-12-31 1815000000
1 TRI.TO 2023-11-01 06:30:00 2023-09-30 1594000000
2 TRI.TO 2023-08-02 06:30:00 2023-06-30 1647000000
3 TRI.TO 2023-05-02 06:30:00 2023-03-31 1738000000
4 TRI.TO 2023-02-09 06:30:00 2022-12-31 1765000000
5 TRI.TO 2022-11-01 06:30:00 2022-09-30 1574000000
6 TRI.TO 2022-08-04 06:30:00 2022-06-30 1614000000
7 TRI.TO 2022-05-03 06:30:00 2022-03-31 1674000000
8 TRI.TO 2022-02-08 06:30:00 2021-12-31 1710000000
Hide code cell content
rd.close_session()