Total Returns and Price Returns over specific periods

Is there a way to get the total return and the price return of an index using the python API? Specifically, i was looking for total return and price return for 5 year periods (2000-01-01 to 2004-12-31, 2005-01-01 to 2009-12-31, 2010-01-01 to 2014-12-31 and 2015-01-01 to 2019-12-31) for STI. i can see the chart/data on .STI TRTR and can pull the timeseries for .STI and .TRISTI (the total return STI) but was looking to write an pythonic query to get the information as a single api request rather than having to get the two series and then compute returns etc separately.

Best Answer

  • Hi @rajanraju

    You can calculate that in a single query.

    df,err = ek.get_data(['.TRISTI','.STI'], 'TR.PriceClose(SDate=2004-12-31)/TR.PriceClose(SDate=1999-12-31)-1')

    image

Answers