How can I use the result of first code as universe for the second set of codes in python API?

For example

=@TR(TR(TR(M20,"TR.FiIssuerOrganization","CODE:ISIN"),"TR.CreditRatioPD")

This one retrieves first the issuer organization id from the ISIN of the bond

Then after getting the organization ID, it gets the default probability. All in one go.

So the formula has 2 layers, one for getting org id, then another for getting def prob.

So would you know a way in python, where we can use the result of the first set of codes as the universe of the second?

Answers

  • @johnnavi.quinones

    Thank you for reaching out to us.

    The TR Excel function is similar to the get_data method in the LSEG Data Library for Python. You can refer to the examples on GitHub.

    You can use the output of the first call as an input of the second call. For example:

    df = ld.get_data(universe = ['US449276AA20'], 
                fields = ['TR.FiParentIssuerOrganization'])


    df1 = ld.get_data(
        universe=df["Parent Issuer Organization"].to_list(),
        fields=['TR.CreditRatioPD','TR.CommonName'])


    df1

    1725527946346.png