unable to successfully pull time series for US BMK

Hello - I want to pull a historic yield time series for at least US10YT=RR, but I'd like to include other RICs too (for instance US1YT=RR). I've tried many variations of the following and I can't successfully pull any yields. Should I prefer get_data to get_timeseries? Does it matter if I want to pull for more than one RIC? Here are examples of my failing codes. The equivalent codes in Excel do pull data.


import eikon as ek

ek.set_app_key('xxx')

df1, err = ek.get_data('US10YT=RR', 'B_YLD_1', {'SDate':'2020-01-01','Frq':'D','EDate':'2022-01-31'})
print(df1)


df2, err = ek.get_timeseries('US10YT=RR', 'B_YLD_1', start_date='2020-01-01', end_date='2022-01-31')
print(df2)

Best Answer

  • Jirapongse
    Answer ✓


    The get_timeseries method support the 'TIMESTAMP', 'VALUE', 'VOLUME', 'HIGH', 'LOW', 'OPEN', 'CLOSE', 'COUNT' fields. Therefore, the code looks like this.

    df2 = ek.get_timeseries('US10YT=RR', start_date='2020-01-01', end_date='2022-01-31')
    df2

    1653282072543.png

    You can also use the get_data method with the TR.BIDYIELD field, as shown below.

    df1, err = ek.get_data('US10YT=RR', ['TR.BIDYIELD','TR.BIDYIELD.Date'],
                           {'SDate':'2020-01-01','Frq':'D','EDate':'2022-01-31'})
    df1

    The output is:

    1653282452822.png

    You can use the Data Item Browser tool to find available fields which can be used with the get_data method. For more information, please refer to this video.

Answers

  • hi @ELLing ,

    First of all, the ek.get_timeseries function only returns a dataframe so the code should be like this instead (remove assigning the output to err variable for get_timeseries function)

    df2 = ek.get_timeseries('US10YT=RR', 'B_YLD_1', start_date='2020-01-01', end_date='2022-01-31')

    Next, printing an error from ek.get_data function shows that the field used (B_YLD_1) was not found in response for this instrument, which is a content-related issue that it's recommended to ask the content specialist by raising a ticket via MyRefinitiv

    However, I'll try to find the proper function/field to be used here so, could you please provide the Excel formula that you used?

    1653279315069.png


  • Hi Raksina,

    thank you for your response. If we can fix the field, will I be able to get data for more than one RIC at the same time with the same call? Also, for time series, should I prefer get_data or get_timeseries?


    The formula in Excel that works is below:

    =RDP.HistoricalPricing("US10YT=RR","B_YLD_1","START:02-Jan-2022 END:23-May-2022 INTERVAL:P1D SOURCE:RFV",,"CH:Fd RH:Timestamp",B2)

  • Hi @LRE42 ,

    In addition to my colleague's reply, I
    would recommend you look at the newer RD Library for Python - which is currently in Beta and
    due for release in the coming months.

    It will also have fuller
    documentation - I have been advised by the RD Library team that they are
    awaiting the completion of the documentation to confirm the release date.

    import refinitiv.data as rd
    rd.open_session()
    rd.get_history(universe="US10YT=RR", fields="B_YLD_1", interval="1D", start="2022-01-02", end="2022-05-23")

    I've compared the output with your Excel formula and the result are matched

    1653289160894.png

    Please let me know in case you have any further questions

  • Thank you, all. This is helpful. @raksina.samasiri, is there a refinitiv.data equivalent for get_data for this same RIC and field?

  • Hi @LRE42

    There are a number of GitHub examples demonstrating the functionality within the Refinitiv Data Library for Python. In there, you can see examples related to get_data.

  • this was also helpful - thanks