<jupyter_start><jupyter_text>Refinitiv Data Platform Library for Python Delivery - EndPoint - Quantitative Analytics - Financial Contracts This notebook demonstrates how the Delivery Layer of the library can be used to perform Quantitative Analytics on the Refinitiv Data Platform - using the Delivery Layer's Endpoint interface to retrieve content directly from the Endpoint.  Set the location of the configuration fileFor ease of use, you can set various initialization parameters of the RD Library in the **_refinitiv-data.config.json_** configuration file - as described in the Quick Start -> Sessions example. One config file for the tutorialsAs these tutorial Notebooks are categorised into sub-folders and to avoid the need for multiple config files, we will use the _RD_LIB_CONFIG_PATH_ environment variable to point to a single instance of the config file in the top-level ***Configuration*** folder.Before proceeding, please **ensure you have entered your credentials** into the config file in the ***Configuration*** folder.<jupyter_code>import os
os.environ["RD_LIB_CONFIG_PATH"] = "../../../Configuration"
from refinitiv.data.delivery import endpoint_request
import refinitiv.data as rd
import pandas as pd
import json<jupyter_output><empty_output><jupyter_text>Open the default sessionTo open the default session ensure you have a '*refinitiv-data.config.json*' in the ***Configuration*** directory, populated with your credentials and specified a 'default' session in the config file<jupyter_code>rd.open_session()<jupyter_output><empty_output><jupyter_text>Define the endpoint request<jupyter_code>request_definition = rd.delivery.endpoint_request.Definition(
    url = "/data/quantitative-analytics/beta1/financial-contracts",
    method = rd.delivery.endpoint_request.RequestMethod.POST,
    body_parameters = {
                          "fields": [
                            "InstrumentCode",
                            "BondType",
                            "IssueDate",
                            "EndDate",
                            "CouponRatePercent",
                            "Accrued",
                            "CleanPrice",
                            "DirtyPrice",
                            "YieldPercent",
                            "RedemptionDate",
                            "ModifiedDuration",
                            "Duration",
                            "DV01Bp",
                            "AverageLife",
                            "Convexity"
                          ],
                          "outputs": [
                            "Headers",
                            "Data"
                          ],
                          "universe": [
                            {
                              "instrumentType": "Bond",
                              "instrumentDefinition": {
                                "instrumentTag": "TreasuryBond_10Y",
                                "instrumentCode": "US10YT=RR"
                              }
                            }
                          ]
                    }
)<jupyter_output><empty_output><jupyter_text>Send a request<jupyter_code>response = request_definition.get_data()<jupyter_output>https://api.refinitiv.com /data/quantitative-analytics/beta1/financial-contracts None None<jupyter_text>Display the result Notice how the response contains the column headings for the data<jupyter_code>if response.is_success:
    headers = [h['name'] for h in response.data.raw['headers']]
    df = pd.DataFrame(data=response.data.raw['data'], columns=headers)
    display(df)<jupyter_output><empty_output><jupyter_text>Close the session<jupyter_code>rd.close_session()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07803700724054706, 'fraction_numerical': 0.002145347278090641, 'mean_word_length': 2.0300568643379364, 'pattern_counts': {'":': 7, '<': 24, '<?xml version=': 0, '>': 25, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '51556', 'license': 'Apache-2.0', 'n_tokens_mistral': 924, 'n_tokens_neox': 888, 'n_words': 255, 'path': 'Tutorials/3.Delivery/3.2-Endpoint/TUT_3.2.03-EndPoint-IPA-FinancialContracts.ipynb', 'repo_name': 'Refinitiv-API-Samples/Example.DataLibrary.Python', 'size': '3729'}