historical index valuation ratio via Eikon API

Hello, I am looking for historical index valuation ratios e.g. P/E ratio for the SP500. I know how to pull it for individual stocks but I dont get any result when I put the index RIC. Is there a way to get them or have to do it the hard way, i.e. pulling historical constituents and estimating the index aggregate ratio?

Best Answer

  • Agnes Terada
    Answer ✓

    Hi @ninja,

    You can use the following code to retrieve historical PE for the S&P 500:

    spx_pe, err = ek.get_data(['.SPX'], ['TR.Index_PE_RTRS.date' ,'TR.Index_PE_RTRS'], {'SDate':'0D','EDate':'-1CY'})

    image

Answers