question

Upvotes
23 0 0 2

Python refinitiv fundamental returning wrong data -- very weird an incoherent behavior

I'm using the Refinitiv package in python, following code, and receive wrong data back, also depending on the parameters.

The code:

import refinitiv.data as rd
from refinitiv.data.content import fundamental_and_reference

rd.open_session()


fields = [
    'TR.F.TotRevenue.fperiod',
    'TR.F.TotRevenue',
    'TR.F.COGSTot.fperiod',
    'TR.F.COGSTot',
    'TR.F.IncTaxDef.fperiod',
    'TR.F.IncTaxDef'
]

parameters =  {
        "SDate": '-30Y',
        "EDate": '-1d',
        "FRQ": "FY", # frequency, full year
        "Scale": 3, # in thousands
        "Curn": 'EUR',
    }

response = fundamental_and_reference.Definition(
            universe=['5056437385'], 
            fields=fields,
            use_field_names_in_headers=True,
            parameters=parameters
        ).get_data()

df = response.data.df

print(df)


This returns a dataframe with data from 2001 to 2018, formatted as EUR. See below:

1.jpeg

There are 2 problems with dataframe:

1. The years FY2007 is double. Why is this?

2. The value for "TR.F.IncTaxDef" is different for each row. First row is 560 and second row is -455.

The data can be verified in the Refinitiv Workspace app, searching for instrument 5056437385, then opening the financials and opening the income statement. Revenue for all years are correct. The IncTaxDef should be -605. See:

2.jpg

What we can do is zoom into the years, using parameters:

parameters =  {
        "SDate": '-18Y',
        "EDate": '-14Y',
        "FRQ": "FY", # frequency, full year
        "Scale": 3, # in thousands
        "Curn": 'EUR',
    }

The same code results in:

schermafbeelding-2024-05-20-om-133800.png

As you can see: the IncTaxDef is correct, -605. However there is no COGS. Also 2007 is double.


This is very weird and incoherent behavior. In the working of the API I would expect:

1. If the parameter FRQ is "FY", then I would expect that each row is a unique year. How come 2007 is double?

2. If we adjust Sdate/Edate, then this should not change the data. How come if I search for past 30Y I get a different value for the income tax then if I search for -18Y.

3. The API should result in the same values as found in the financial report of the app. How come the tax income is different for 2007?

What is going on and can you help to get coherent code working?

Thanks



python#contentfundamental-data
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
10.6k 20 6 9

@r.fernandez so I would use the get_history function as that has row fidelity in the returns. If I do that I can see that there was a change in book closing period in 2007. So essentially there are 2 entries in this return - but I agree it is not correct. However look at rd.get_history function return for the full period:

rd.get_history(universe=["5056437385"], 
               fields=['TR.F.TotRevenue.fperiod','TR.F.TotRevenue','TR.F.COGSTot.fperiod','TR.F.COGSTot','TR.F.IncTaxDef.fperiod','TR.F.IncTaxDef'], 
               interval="1Y",
               parameters = {"SDate": '-30Y',"EDate": '-1D',"FRQ": "FY","Scale": 3, "Curn": 'EUR'},
              use_field_names_in_headers=True)

1716391416484.png


If I then change the call to reflect your second request:

rd.get_history(universe=["5056437385"], 
               fields=['TR.F.TotRevenue.fperiod','TR.F.TotRevenue','TR.F.COGSTot.fperiod','TR.F.COGSTot','TR.F.IncTaxDef.fperiod','TR.F.IncTaxDef'], 
               interval="1Y",
               parameters = {"SDate": '-18Y',"EDate": '-14Y',"FRQ": "FY","Scale": 3, "Curn": 'EUR'},
              use_field_names_in_headers=True)

1716391665383.png

It is the same as get_history - I will check with the team involved about the get_history return - but I believe we have at least isolated it to the change in book closing. The code for the get_history function is also a lot cleaner than using the content layer definition.I hope this can help.


1716391416484.png (308.2 KiB)
1716391665383.png (171.8 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.

Upvotes
23 0 0 2

Hi @jason.ramchandani01

Can you explain or show me the documentation that explains what row fidelity is and the concepts behind row fidelity?


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
23 0 0 2

@jason.ramchandani01

Can you explain the following strange behavior. Perhaps this has to do with row fidelity, but I'm not sure what this means. However, applying your code with an extended field TR.F.MktCap generates extra rows. Let me show you. The code:

parameters = {
        "SDate": '-18Y',
        "EDate": '-14Y',
        "FRQ": "FY", # frequency, full year
        "Scale": 3, # in thousands
        "Curn": 'EUR',
    }
df = rd.get_history(universe=['5056437385'], 
                    fields=[
                        'TR.F.TotRevenue',
                        'TR.F.COGSTot',
                        'TR.F.IncTaxDef'], 
                    interval="1Y",
                    use_field_names_in_headers=True,
                    parameters = parameters)
rd.close_session()

print(df)

This generates the following, completely logical data:

schermafbeelding-2024-05-23-om-091807.jpg

When I add the column TR.F.MktCap in fields we get the following:

schermafbeelding-2024-05-23-om-092007.jpg


Logical behavior: The row 2008 is now filled with market cap, no data is the for revenue and tax because of update in closing booker.

Illogical behavior: row 2007 is doubled. Data revenue/tax is applied twice. Marketcap is only visible in first row.


Can you explain this behavior?


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.

And also 2nd illogical behavior. 2008 is doubled as well, 30 may and 31 December. For this the second has no data.
Upvotes
6.2k 18 2 8

Hi @r.fernandez ,


I checked your code above with RD version 1.6.1 and it seems the issue you are facing is now resolved. Can you please check and confirm?

See below by request/response:

parameters = {
        "SDate": '-18Y',
        "EDate": '-14Y',
        "FRQ": "FY", # frequency, full year
        "Scale": 3, # in thousands
        "Curn": 'EUR',
    }
df = rd.get_history(universe=['5056437385'], 
                    fields=[
                        'TR.F.TotRevenue',
                        'TR.F.COGSTot',
                        'TR.F.IncTaxDef'], 
                    interval="1Y",
                    use_field_names_in_headers=True,
                    parameters = parameters)


screenshot-2024-07-15-at-103519.png

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.

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.