Is it possible to retrieve government bond discount factors using Eikon APIs?

This seems to be possible using the RHistory function in Excel, but not using one of the Eikon APIs in Python. The get_timeseries does not provide discount factors.

Best Answer

  • chavalit-jintamalit
    Answer ✓

    Hi @mark.snijder

    You can install RDP Library by using this command:

    pip install refinitiv.dataplatform

    image


    Then in your code, you can add this code, the RDP Library will connect to your Eikon Desktop(similar to Eikon Data API):

    import refinitiv.dataplatform as rdp
    rdp.open_desktop_session('<valid app key>')

    df= rdp.get_historical_price_summaries('PLGOV1YZ=R', start='20210201', end='20210215')
    display(df)

Answers

  • @mark.snijder

    I suppose what you would like to retrieve is timeseries of discount factors for various points on the zero curve derived from Treasuries, right? If this is the case, you can do this using RDP Libraries. Here's a the call using 10Y maturity point on US Treasuries zero curve.

    rdp.get_historical_price_summaries('USGOV10YZ=R')

    If you would like to retrieve something else, could you provide an example of RHistory function that retrieves the data you're interested in?

  • @Alex Putkov.

    I have made a comparison in Excel for the 1Y Polish Government Bond rate (PLGOV1YZ=R). Retrieving both the discount factors and zero yields would result in the following:


    Discount factor

    image.png

    Zero yield

    image.png


    When using the ek.get_timeseries() function in Python I am only able to retrieve the zero yields, which I can't transform to the discount factors (probably there is some smoothing involved). Are the discount factors available from the RDP library? What is the difference between the RDP.get_historical_price_summaries() function and the ek.get_timeseries() function?

  • Hi @mark.snijder

    The discount factor is available from the RDP Library.

    The difference between EK vs RDP is:

    • Eikon.get_timeseries can only retrieve "default" view data.
    • RDP.get_historical_price_summaries can cover more views.

    image

  • That is the solution I was looking for! Thanks for your help!

  • I should add to the answer by @chavalit.jintamalit that RDP Library for Python includes Eikon Data APIs as a module. Hence you can use both Eikon Data APIs and RDP Libraries methods from the same library. The following example uses Eikon Data APIs to retrieve the constituents of the Polish Treasuries zero curve, and then uses get_historical_price_summaries method of RDP Libraries to retrieve timeseries for the 1Y maturity point on the curve.

    import refinitiv.dataplatform as rdp
    import refinitiv.dataplatform.eikon as ek
    rdp.open_desktop_session('MY_APP_KEY')

    tmp_df, err = ek.get_data('0#PLXZ=R',['TENOR'])
    df= rdp.get_historical_price_summaries(
        tmp_df.loc[tmp_df['TENOR']=='1Y','Instrument'].iloc[0], 
        start = '20210201', 
        end = '20210215')
    display(df)