Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 0 1

How can I run this API endpoint on CodeBook?

How can I run this API endpoint on CodeBook?


I'm trying to run the following function, but the output is the following problem
"error
0 {'id': '62dc1e15-2ef8-4d91-b0bb-83e4739233d2/6...",how could this be converted to get currency forward data?


Full script:


response = ipa.curve.Curves().get_curve(
universe=[ipa.curve.ForwardCurve(
curve_definition=ipa.curve.SwapZcCurveDefinition(
currency="EUR",
index_name="EURIBOR",
discounting_tenor="OIS"),
forward_curve_definitions=[
ipa.curve.ForwardCurveDefinition(
index_tenor="3M",
forward_curve_tag="ForwardTag",
forward_start_date="2024-03-24",
forward_curve_tenors=
["0D",
"1D",
"2D",
"3M",
"6M",
"9M",
"1Y",
"2Y",
"3Y",
"4Y",
"5Y",
"6Y",
"7Y",
"8Y",
"9Y",
"10Y",
"15Y",
"20Y",
"25Y"]
)
]
)
],
outputs=["Constituents"])
response.data.df


Related:

https://api.refinitiv.com/data/quantitative-analytics-curves-and-surfaces/v1/curves/forward-curves


Can we convert this to run on CodeBook? What should be the script? Thank you.

pythonworkspace#technologycodebookrefinitiv-data-librariesendpoint
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.

Hi @kevin.clemente ,

Would you mind letting us know which answer is most appropriate with the 'Accept' button to the left of the answer?

Thank you,

kind regards,

AHS

Upvotes
Accepted
79.2k 251 52 74

@kevin.clemente

I am not sure what ipa.curve.Curves().get_curve method is.

However, the ipa.curve.ForwardCurve code should look like this in CodeBook.

import refinitiv.data as rd
from refinitiv.data.content.ipa.curves import forward_curves

rd.open_session()

response = forward_curves.Definition(
    curve_definition=forward_curves.SwapZcCurveDefinition(
                currency="EUR",
                index_name="EURIBOR",
                name="EUR EURIBOR Swap ZC Curve",
                discounting_tenor="OIS"),
    forward_curve_definitions=[
            forward_curves.ForwardCurveDefinition(
                index_tenor="3M",
                forward_curve_tag="ForwardTag",
                forward_start_date="2024-03-31",
                forward_curve_tenors=["0D","1D","2D","3M","6M","9M","1Y","2Y","3Y","4Y","5Y","6Y","7Y","8Y","9Y","10Y","15Y","20Y","25Y"]
                )
            ]
).get_data()


response.data.df

The output is:

1711528199756.png



1711528199756.png (17.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.

Upvotes
24.7k 54 17 14

Hello @kevin.clemente

Thank you for reaching out to us. You can use the Endpoint feature of the Data Library for Python to send the HTTP request to the Delivery Platform API endpoint directly. The Endpoint feature resources are as follows:

If you are on the Codebook, there are the IPA Curve with Endpoint feature available on the __Example__/03. Quantitative Analytics/03.08. Curves folder as follows:

codebook.png

About the code with https://api.refinitiv.com/data/quantitative-analytics-curves-and-surfaces/v1/curves/forward-curves endpoint, the example code can be like this:

response = rd.delivery.endpoint_request.Definition(
    method=rd.delivery.endpoint_request.RequestMethod.POST,
    url="https://api.refinitiv.com/data/quantitative-analytics-curves-and-surfaces/v1/curves/forward-curves",
    body_parameters={
      "universe": [
        {
          "curveDefinition": {
              "currency": "EUR",
              "indexName": "EURIBOR",
              "name": "EUR EURIBOR Swap ZC Curve",
              "discountingTenor": "OIS"
          },
            "forwardCurveDefinitions": [ {
                "indexTenor": "3M",
                "forwardCurveTag": "ForwardTag",
                "forwardStartDate": "2021-02-01",
                "forwardCurveTenors": [
                    "0D","1D","2D","3M","6M","9M","1Y","2Y","3Y","4Y","5Y","6Y","7Y", "8Y","9Y","10Y","15Y", "20Y","25Y"]
            }
            ]
        }
      ]
    }
  ).get_data()


if response.is_success:
    print(response.data)
else:
    display(response.errors)

Result:

code.png



codebook.png (96.7 KiB)
code.png (100.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.

Upvotes
79.2k 251 52 74

@kevin.clemente

I couldn't find how to set the "outputs" parameter in the forward_curves.Definition.

However, you can set in the request message, as shown below.

response = rd.delivery.endpoint_request.Definition(
    method=rd.delivery.endpoint_request.RequestMethod.POST,
    url="https://api.refinitiv.com/data/quantitative-analytics-curves-and-surfaces/v1/curves/forward-curves",
    body_parameters={
      "universe": [
        {
          "curveDefinition": {
              "currency": "EUR",
              "indexName": "EURIBOR",
              "name": "EUR EURIBOR Swap ZC Curve",
              "discountingTenor": "OIS"
          },
            "forwardCurveDefinitions": [ {
                "indexTenor": "3M",
                "forwardCurveTag": "ForwardTag",
                "forwardStartDate": "2024-03-24",
                "forwardCurveTenors": [
                    "0D","1D","2D","3M","6M","9M","1Y","2Y","3Y","4Y","5Y","6Y","7Y", "8Y","9Y","10Y","15Y", "20Y","25Y"]
            }
            ]
        }
      ],
      "outputs":["Constituents"]
    }
  ).get_data()
 
 
if response.is_success:
    display(response.data.raw)
else:
    display(response.errors)
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.