Extracting multiple historic relative valuation ratios via Eikon API (python)

Hi,

I'm hoping someone may be able to help me with the following issue. I'm new to python so this may seem like a novice request. Apologies in advance.

I wish to extract relative valuation data (P/E, P/B, P/S, EV/EBITDA - all TTM) on all S&P500 constituent stocks for the period 2006-2021 into a table on python. What is the cleanest way to code this? I have tried manually including each RIC & also (unsuccessfully) manipulating the 'peers' function.

I'm aware there will be leavers and joiners included in the dataset but that does not pose an issue to the research I then plan to complete on the dataset.

I've read numerous other threads that pose a similar question but I haven't been able to successfully alter their code to achieve my goal. I can share my code thus far if it helps.

Thank you!

Best Answer

  • [Deleted User]
    [Deleted User] Newcomer
    Answer ✓

    Hi @student.02 ,


    Please use the Data Item Browser to find the fields you're after

    1657525341876.png


    1657525362050.png


    import refinitiv.data as rd
    rd.open_session()
    df1 = rd.get_history(
    universe=["0#.SPX"],
    fields=["TR.PE"],
    interval="1D",
    start="2021-10-01",
    end="2021-10-03",
    )
    display(df1)
    rd.close_session()




Answers