Hi, I want to download time series data for government and corporate bond yields. I found the screen

Hi, I want to download time series data for government and corporate bond yields. I found the screens with current data but I could not retrieve any historical (time series) data. Thank you!

Best Answer

Answers

  • Here's a quick example

    import refinitiv.dataplatform as rdp
    rdp.open_desktop_session('USE_YOUR_APP_KEY_HERE')
    rdp.get_historical_price_summaries(
            universe = '345370BR0=',
            start = '2020-12-10',
            end = '2020-12-26',
            fields=['MID_YLD_1'])

    For more examples see Jupyter notebooks demonstrating Historical Pricing under RDP Library examples in Refinitiv API Samples repository on Github.

  • Hi Alex, thank you for the answer

    Just want to comment that I run the code and it seems that it is executed however I do not see any output.

    image

    I also run the code in Jupiter and the output was presented

    image

    Should I run any other command?

    Thank you in advance


  • Jupyter (or rather IPython) by default displays the results of the execution of the last line of code in the cell. Other Python interpreters, like the one used by Spyder, don't do that. With regular Python interpreter, to display any output on the screen, you need to explicitly include this action in your code. E.g.

    df = rdp.get_historical_price_summaries(
             universe = '345370BR0=',
             start = '2020-12-10',
             end = '2020-12-26',
             fields=['MID_YLD_1'])
    print(df)
  • Thank you for your answer. The code works well. How can I obtain data for multiple series in universe e.g.

    universe = '345370BR0= 'GR176298006= and so on. Thank you

  • Thank you for your answer. The code works well. How can I obtain data for multiple series in universe e.g.

    universe = '345370BR0= 'GR176298006= and so on. Thank you

  • Thank you for the response! It works!

  • Hi,

    In relation to a previous comment, how can I download the output data into an excel? For example the first column dates, the second column the MID_YLD_1 for the first RIC, the third column the MID_YLD_1 for the second RIC, and so on.


    Thank you in advance,

  • get_historical_price_summaries method of RDP library can only retrieve one instrument at a time. To retrieve timeseries for multiple instruments you need to do it sequentially, one instrument at a time.

  • Hi @evan.salachas

    If you have a new question, it is advised to start a new question.


    To export dataframe to excel file, you can refer to the sample on this page.

    https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_excel.html

    image

  • @evan.salachas

    If you'd like to save the data you retrieved in Python as a file you can open in Excel, use to_excel or to_csv method of pandas library, as @chavalit.jintamalit said. And if you'd like to retrieve the data directly into Excel, use RHistory worksheet function provided by Eikon Excel add-in, e.g.

    =RHistory("345370BR0=","MID_YLD_1.Timestamp;MID_YLD_1.Close","INTERVAL:1D",,"CH:Fd")