How do I get Clean Price for US treasuries

I am trying the following, but it is not finding the field and fills the dataframe with <NA>s


df = ek.get_timeseries(

'US5YT=RR',

fields = ['TR.CLEANPRICE']

)


display(df)


Best Answer

  • raksina.samasiri
    Answer ✓

    Hi @Rana.Mallah ,

    I'd like to add that to get the historical data of clean price, the parameters of start date (SDate) and end date (EDate) can be added into the get_data function, please find an example code below

    • 0D mean Last Trading Day and -10D mean 10 day before that
    • or you can use the absolute date on SDate and EDate as well, For example,
      parameters={'SDate':'2021-09-01', 'EDate':'2021-09-20'}
    df, err = ek.get_data('US5YT=RR', fields = ['TR.CLEANPRICE.date', 'TR.CLEANPRICE']
    , parameters = {'SDate':'-10D', 'EDate':'0D'})
    df

    1639564932787.png


Answers

  • Hi @Rana.Mallah ,

    The reason you are getting NA is that your are calling get_timeseries on a property supporting "As of" not the "series". If you use get_data instead, you will get the value you are looking for.

    df, err = ek.get_data('US5YT=RR',fields = ['TR.CLEANPRICE'])
    df

    1639564513580.png