API Call for Treasury Price not Yield

When I make a call in Python such as the one below, I get OHLC quoted in yields:

df = ek.get_timeseries('AU3YT=RR', start_date = '2000-01-01', end_date = '2021-04-20')

However, in excel I can do a similar call, but get the price (and the yield if I want):

=@RHistory("AU3YT=RR","ASK.Timestamp;ASK.Close","INTERVAL:1D",,"TSREPEAT:NO CH:Fd",D4)

Is there a way to edit my python call to get bond price instead of yield?

Best Answer

  • Hi @michael01,

    I would suggest you use the DIB (Data Item Browser) within the desktop to help you hunt down the specific fields you need. Once done, you can use the following get_data() call, for example:

    df, err = ek.get_data('AU3YT=RR', ['TR.ASKPRICE', 'TR.ASKPRICE.date'], 
                          parameters = {'SDate': 0,'EDate': -10,'Frq': 'D'})
    df

    image

Answers

  • @michael01 Please try the following:

    df,err = ek.get_data('AU3YT=RR',['TR.AskPrice.date','TR.AskPrice'],{'SDate':'2000-01-01','EDate':'2021-04-20','Frq':'D'})

    df

    image

    I hope this can help.